blob: 0b6e9f86fa1172001c388f889f909255a4fa020c [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"
subrata_modak8da4f072009-05-21 18:33:24 +000045#include "linux_syscall_numbers.h"
46
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020047char *TCID = "set_tid_address01";
Wanlong Gao354ebb42012-12-07 10:10:04 +080048int testno;
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020049int TST_TOTAL = 1;
subrata_modak8da4f072009-05-21 18:33:24 +000050
51/* Extern Global Functions */
52/******************************************************************************/
53/* */
54/* Function: cleanup */
55/* */
56/* Description: Performs all one time clean up for this test on successful */
57/* completion, premature exit or failure. Closes all temporary */
58/* files, removes all temporary directories exits the test with */
59/* appropriate return code by calling tst_exit() function. */
60/* */
61/* Input: None. */
62/* */
63/* Output: None. */
64/* */
65/* Return: On failure - Exits calling tst_exit(). Non '0' return code. */
66/* On success - Exits calling tst_exit(). With '0' return code. */
67/* */
68/******************************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -040069void cleanup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080070{
Garrett Cooper2c282152010-12-16 00:55:50 -080071
Wanlong Gao354ebb42012-12-07 10:10:04 +080072 tst_rmdir();
subrata_modak8da4f072009-05-21 18:33:24 +000073
Wanlong Gao354ebb42012-12-07 10:10:04 +080074 tst_exit();
subrata_modak8da4f072009-05-21 18:33:24 +000075}
76
77/* Local Functions */
78/******************************************************************************/
79/* */
80/* Function: setup */
81/* */
82/* Description: Performs all one time setup for this test. This function is */
83/* typically used to capture signals, create temporary dirs */
84/* and temporary files that may be used in the course of this */
85/* test. */
86/* */
87/* Input: None. */
88/* */
89/* Output: None. */
90/* */
91/* Return: On failure - Exits by calling cleanup(). */
92/* On success - returns 0. */
93/* */
94/******************************************************************************/
Mike Frysingerc57fba52014-04-09 18:56:30 -040095void setup(void)
Wanlong Gao354ebb42012-12-07 10:10:04 +080096{
97 /* Capture signals if any */
98 /* Create temporary directories */
99 TEST_PAUSE;
100 tst_tmpdir();
subrata_modak8da4f072009-05-21 18:33:24 +0000101}
102
Wanlong Gao354ebb42012-12-07 10:10:04 +0800103int main(int ac, char **av)
104{
105 int newtid = -1;
Cyril Hrubis89af32a2012-10-24 16:39:11 +0200106 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +0200107 const char *msg;
Garrett Cooper2c282152010-12-16 00:55:50 -0800108
Wanlong Gao354ebb42012-12-07 10:10:04 +0800109 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
110 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
Wanlong Gao354ebb42012-12-07 10:10:04 +0800111 }
subrata_modak8da4f072009-05-21 18:33:24 +0000112
Wanlong Gao354ebb42012-12-07 10:10:04 +0800113 setup();
subrata_modak8da4f072009-05-21 18:33:24 +0000114
Wanlong Gao354ebb42012-12-07 10:10:04 +0800115 for (lc = 0; TEST_LOOPING(lc); ++lc) {
Caspar Zhangd59a6592013-03-07 14:59:12 +0800116 tst_count = 0;
Wanlong Gao354ebb42012-12-07 10:10:04 +0800117 for (testno = 0; testno < TST_TOTAL; ++testno) {
Jan Stancek359980f2013-02-15 10:16:05 +0100118 TEST(ltp_syscall(__NR_set_tid_address, &newtid));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800119 if (TEST_RETURN == getpid()) {
120 tst_resm(TPASS,
121 "set_tid_address call succeeded: as expected %ld",
122 TEST_RETURN);
123 } else {
Cyril Hrubis9fa8ad02014-12-16 13:20:49 +0100124 tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s",
Wanlong Gao354ebb42012-12-07 10:10:04 +0800125 TCID, TEST_ERRNO,
126 strerror(TEST_ERRNO));
Wanlong Gao354ebb42012-12-07 10:10:04 +0800127 }
128 }
129 }
subrata_modak8da4f072009-05-21 18:33:24 +0000130 cleanup();
Wanlong Gao354ebb42012-12-07 10:10:04 +0800131 tst_exit();
Chris Dearmanec6edca2012-10-17 19:54:01 -0700132}