• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Crackerjack Project
3  *
4  * Copyright (C) 2007-2008, Hitachi, Ltd.
5  * Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
6  *            Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
7  *            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22  *
23  * $Id: gettid01.c,v 1.5 2009/10/26 14:55:47 subrata_modak Exp $
24  *
25  */
26 
27 /* Porting from Crackerjack to LTP is done
28    by Masatake YAMATO <yamato@redhat.com> */
29 
30 #include <sys/types.h>
31 #include <linux/unistd.h>
32 #include <errno.h>
33 
34 #include "test.h"
35 
36 void setup();
37 void cleanup();
38 
39 char *TCID = "gettid01";
40 
41 int TST_TOTAL = 1;
42 
my_gettid(void)43 pid_t my_gettid(void)
44 {
45 	return (pid_t) syscall(__NR_gettid);
46 }
47 
main(int ac,char ** av)48 int main(int ac, char **av)
49 {
50 	int lc;
51 
52 	tst_parse_opts(ac, av, NULL, NULL);
53 
54 	setup();
55 
56 	/*
57 	 * The following loop checks looping state if -c option given
58 	 */
59 	for (lc = 0; TEST_LOOPING(lc); lc++) {
60 
61 		tst_count = 0;
62 
63 		TEST(my_gettid());
64 
65 		if (TEST_RETURN == -1) {
66 			tst_resm(TFAIL, "gettid() Failed, errno=%d: %s",
67 				 TEST_ERRNO, strerror(TEST_ERRNO));
68 		} else {
69 			tst_resm(TPASS, "gettid() returned %ld",
70 				 TEST_RETURN);
71 		}
72 	}
73 
74 	cleanup();
75 	tst_exit();
76 }
77 
78 /*
79  * setup() - performs all ONE TIME setup for this test.
80  */
setup(void)81 void setup(void)
82 {
83 
84 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
85 
86 	TEST_PAUSE;
87 
88 }
89 
90 /*
91  * cleanup() - performs all ONE TIME cleanup for this test at
92  *		completion or premature exit.
93  */
cleanup(void)94 void cleanup(void)
95 {
96 }
97