blob: be23dbc9d2458112c4a94524df99846fa3abb63f [file] [log] [blame]
subrata_modak8da4f072009-05-21 18:33:24 +00001/******************************************************************************/
2/* Copyright (c) Crackerjack Project., 2007 */
3/* */
4/* This program is free software; you can redistribute it and/or modify */
5/* it under the terms of the GNU General Public License as published by */
6/* the Free Software Foundation; either version 2 of the License, or */
7/* (at your option) any later version. */
8/* */
9/* This program is distributed in the hope that it will be useful, */
10/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
12/* the GNU General Public License for more details. */
13/* */
14/* You should have received a copy of the GNU General Public License */
15/* along with this program; if not, write to the Free Software */
Wanlong Gao4548c6c2012-10-19 18:03:36 +080016/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
subrata_modak8da4f072009-05-21 18:33:24 +000017/* */
18/******************************************************************************/
19/******************************************************************************/
20/* */
21/* File: set_tid_address01.c */
22/* */
23/* Description: This tests the set_tid_address() syscall */
24/* */
25/* Usage: <for command-line> */
26/* set_tid_address01 [-c n] [-e][-i n] [-I x] [-p x] [-t] */
27/* where, -c n : Run n copies concurrently. */
28/* -e : Turn on errno logging. */
29/* -i n : Execute test n times. */
30/* -I x : Execute test for x seconds. */
31/* -P x : Pause for x seconds between iterations. */
32/* -t : Turn on syscall timing. */
33/* */
34/* Total Tests: 1 */
35/* */
36/* Test Name: set_tid_address01 */
37/* History: Porting from Crackerjack to LTP is done by */
38/* Manas Kumar Nayak maknayak@in.ibm.com> */
39/******************************************************************************/
40
41#include <stdio.h>
42#include <errno.h>
43
subrata_modak8da4f072009-05-21 18:33:24 +000044#include "test.h"
45#include "usctest.h"
46#include "linux_syscall_numbers.h"
47
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020048char *TCID = "set_tid_address01";
Wanlong Gao354ebb42012-12-07 10:10:04 +080049int testno;
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020050int TST_TOTAL = 1;
subrata_modak8da4f072009-05-21 18:33:24 +000051
52/* Extern Global Functions */
53/******************************************************************************/
54/* */
55/* Function: cleanup */
56/* */
57/* Description: Performs all one time clean up for this test on successful */
58/* completion, premature exit or failure. Closes all temporary */
59/* files, removes all temporary directories exits the test with */
60/* appropriate return code by calling tst_exit() function. */
61/* */
62/* Input: None. */
63/* */
64/* Output: None. */
65/* */
66/* Return: On failure - Exits calling tst_exit(). Non '0' return code. */
67/* On success - Exits calling tst_exit(). With '0' return code. */
68/* */
69/******************************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -040070void cleanup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080071{
Garrett Cooper2c282152010-12-16 00:55:50 -080072
Wanlong Gao354ebb42012-12-07 10:10:04 +080073 TEST_CLEANUP;
74 tst_rmdir();
subrata_modak8da4f072009-05-21 18:33:24 +000075
Wanlong Gao354ebb42012-12-07 10:10:04 +080076 tst_exit();
subrata_modak8da4f072009-05-21 18:33:24 +000077}
78
79/* Local Functions */
80/******************************************************************************/
81/* */
82/* Function: setup */
83/* */
84/* Description: Performs all one time setup for this test. This function is */
85/* typically used to capture signals, create temporary dirs */
86/* and temporary files that may be used in the course of this */
87/* test. */
88/* */
89/* Input: None. */
90/* */
91/* Output: None. */
92/* */
93/* Return: On failure - Exits by calling cleanup(). */
94/* On success - returns 0. */
95/* */
96/******************************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -040097void setup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080098{
99 /* Capture signals if any */
100 /* Create temporary directories */
101 TEST_PAUSE;
102 tst_tmpdir();
subrata_modak8da4f072009-05-21 18:33:24 +0000103}
104
Wanlong Gao354ebb42012-12-07 10:10:04 +0800105int main(int ac, char **av)
106{
107 int newtid = -1;
Cyril Hrubis89af32a2012-10-24 16:39:11 +0200108 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +0200109 const char *msg;
Garrett Cooper2c282152010-12-16 00:55:50 -0800110
Wanlong Gao354ebb42012-12-07 10:10:04 +0800111 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
112 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Wanlong Gao354ebb42012-12-07 10:10:04 +0800113 }
subrata_modak8da4f072009-05-21 18:33:24 +0000114
Wanlong Gao354ebb42012-12-07 10:10:04 +0800115 setup();
subrata_modak8da4f072009-05-21 18:33:24 +0000116
Wanlong Gao354ebb42012-12-07 10:10:04 +0800117 for (lc = 0; TEST_LOOPING(lc); ++lc) {
Caspar Zhangd59a6592013-03-07 14:59:12 +0800118 tst_count = 0;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800119 for (testno = 0; testno < TST_TOTAL; ++testno) {
Jan Stancek359980f2013-02-15 10:16:05 +0100120 TEST(ltp_syscall(__NR_set_tid_address, &newtid));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800121 if (TEST_RETURN == getpid()) {
122 tst_resm(TPASS,
123 "set_tid_address call succeeded: as expected %ld",
124 TEST_RETURN);
125 } else {
Cyril Hrubis9fa8ad02014-12-16 13:20:49 +0100126 tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s",
Wanlong Gao354ebb42012-12-07 10:10:04 +0800127 TCID, TEST_ERRNO,
128 strerror(TEST_ERRNO));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800129 }
130 }
131 }
subrata_modak8da4f072009-05-21 18:33:24 +0000132 cleanup();
Wanlong Gao354ebb42012-12-07 10:10:04 +0800133 tst_exit();
Chris Dearmanec6edca2012-10-17 19:54:01 -0700134}