blob: f37f9f26621d1d0f66354ff130fc86c30e1358db [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
44/* Harness Specific Include Files. */
45#include "test.h"
46#include "usctest.h"
47#include "linux_syscall_numbers.h"
48
49/* Extern Global Variables */
subrata_modak8da4f072009-05-21 18:33:24 +000050
51/* Global Variables */
Wanlong Gao354ebb42012-12-07 10:10:04 +080052char *TCID = "set_tid_address01"; /* Test program identifier. */
53int testno;
54int TST_TOTAL = 1; /* total number of tests in this file. */
subrata_modak8da4f072009-05-21 18:33:24 +000055
56/* Extern Global Functions */
57/******************************************************************************/
58/* */
59/* Function: cleanup */
60/* */
61/* Description: Performs all one time clean up for this test on successful */
62/* completion, premature exit or failure. Closes all temporary */
63/* files, removes all temporary directories exits the test with */
64/* appropriate return code by calling tst_exit() function. */
65/* */
66/* Input: None. */
67/* */
68/* Output: None. */
69/* */
70/* Return: On failure - Exits calling tst_exit(). Non '0' return code. */
71/* On success - Exits calling tst_exit(). With '0' return code. */
72/* */
73/******************************************************************************/
Wanlong Gao354ebb42012-12-07 10:10:04 +080074extern void cleanup()
75{
Garrett Cooper2c282152010-12-16 00:55:50 -080076
Wanlong Gao354ebb42012-12-07 10:10:04 +080077 TEST_CLEANUP;
78 tst_rmdir();
subrata_modak8da4f072009-05-21 18:33:24 +000079
Wanlong Gao354ebb42012-12-07 10:10:04 +080080 tst_exit();
subrata_modak8da4f072009-05-21 18:33:24 +000081}
82
83/* Local Functions */
84/******************************************************************************/
85/* */
86/* Function: setup */
87/* */
88/* Description: Performs all one time setup for this test. This function is */
89/* typically used to capture signals, create temporary dirs */
90/* and temporary files that may be used in the course of this */
91/* test. */
92/* */
93/* Input: None. */
94/* */
95/* Output: None. */
96/* */
97/* Return: On failure - Exits by calling cleanup(). */
98/* On success - returns 0. */
99/* */
100/******************************************************************************/
Wanlong Gao354ebb42012-12-07 10:10:04 +0800101void setup()
102{
103 /* Capture signals if any */
104 /* Create temporary directories */
105 TEST_PAUSE;
106 tst_tmpdir();
subrata_modak8da4f072009-05-21 18:33:24 +0000107}
108
Wanlong Gao354ebb42012-12-07 10:10:04 +0800109int main(int ac, char **av)
110{
111 int newtid = -1;
Cyril Hrubis89af32a2012-10-24 16:39:11 +0200112 int lc;
113 char *msg;
Garrett Cooper2c282152010-12-16 00:55:50 -0800114
Wanlong Gao354ebb42012-12-07 10:10:04 +0800115 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
116 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
117 tst_exit();
118 }
subrata_modak8da4f072009-05-21 18:33:24 +0000119
Wanlong Gao354ebb42012-12-07 10:10:04 +0800120 setup();
subrata_modak8da4f072009-05-21 18:33:24 +0000121
Wanlong Gao354ebb42012-12-07 10:10:04 +0800122 for (lc = 0; TEST_LOOPING(lc); ++lc) {
123 Tst_count = 0;
124 for (testno = 0; testno < TST_TOTAL; ++testno) {
Jan Stancek359980f2013-02-15 10:16:05 +0100125 TEST(ltp_syscall(__NR_set_tid_address, &newtid));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800126 if (TEST_RETURN == getpid()) {
127 tst_resm(TPASS,
128 "set_tid_address call succeeded: as expected %ld",
129 TEST_RETURN);
130 } else {
131 tst_resm(TFAIL, "%s failed - errno = %d : %s",
132 TCID, TEST_ERRNO,
133 strerror(TEST_ERRNO));
134 cleanup();
135 tst_exit();
136 }
137 }
138 }
subrata_modak8da4f072009-05-21 18:33:24 +0000139 cleanup();
Wanlong Gao354ebb42012-12-07 10:10:04 +0800140 tst_exit();
Chris Dearmanec6edca2012-10-17 19:54:01 -0700141}