1/*
2 * Copyright (c) 2004, Bull S.A..  All rights reserved.
3 * Created by: Sebastien Decugis
4
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write the Free Software Foundation, Inc., 59
15 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 *
17
18
19 * This sample test aims to check the following assertion:
20 * The function fails and return EPERM if caller has not the
21 * privilege to perform the operation.
22
23
24
25 * The steps are:
26 * -> if this implementation does not support privileges, return PTS_UNSUPPORTED
27 * -> Otherwise, use the implementation features to come to a situation where
28 *      pthread_mutex_init should fail because of the privileges, and then check
29 *      that the return code is EPERM.
30 * -> return PTS_UNTESTED if the architecture is not present in the test.
31 */
32
33 /* We are testing conformance to IEEE Std 1003.1, 2003 Edition */
34 #define _POSIX_C_SOURCE 200112L
35
36/********************************************************************************************/
37/****************************** standard includes *****************************************/
38/********************************************************************************************/
39 #include <pthread.h>
40 #include <stdio.h>
41 #include <unistd.h>
42 #include <stdlib.h>
43 #include <errno.h>
44 #include <stdarg.h>
45 #include <sys/utsname.h>
46 #include <string.h>
47
48/********************************************************************************************/
49/******************************   Test framework   *****************************************/
50/********************************************************************************************/
51 #include "../testfrmw.h"
52 #include "../testfrmw.c"
53 /* This header is responsible for defining the following macros:
54  * UNRESOLVED(ret, descr);
55  *    where descr is a description of the error and ret is an int (error code for example)
56  * FAILED(descr);
57  *    where descr is a short text saying why the test has failed.
58  * PASSED();
59  *    No parameter.
60  *
61  * Both three macros shall terminate the calling process.
62  * The testcase shall not terminate in any other maneer.
63  *
64  * The other file defines the functions
65  * void output_init()
66  * void output(char * string, ...)
67  *
68  * Those may be used to output information.
69  */
70
71/********************************************************************************************/
72/********************************** Configuration ******************************************/
73/********************************************************************************************/
74#ifndef VERBOSE
75#define VERBOSE 1
76#endif
77
78#ifndef PTS_UNSUPPORTED
79#define PTS_UNSUPPORTED 4
80#endif
81#ifndef PTS_UNTESTED
82#define PTS_UNTESTED 5
83#endif
84
85
86/********************************************************************************************/
87/***********************************    Test case   *****************************************/
88/********************************************************************************************/
89int main(int argc, char * argv[])
90{
91	int ret;
92	struct utsname un;
93
94	output_init();
95	ret = uname(&un);
96	if (ret == -1)
97	{  UNRESOLVED(errno, "Unable to get Implementation name");  }
98
99	#if VERBOSE > 0
100	output("Implementation is: \n\t%s\n\t%s\n\t%s\n", un.sysname, un.release, un.version);
101	#endif
102
103	/* If we are running Linux */
104	if (strcmp(un.sysname, "Linux") == 0 )
105	{
106		/* Linux does not provide privilege access to pthread_mutex_init function */
107		ret = PTS_UNSUPPORTED;
108		output("Linux does not provide this feature\n");
109		output_fini();
110		return ret;
111	}
112
113	/* If we are running AIX */
114	if (strcmp(un.sysname, "AIX") == 0 )
115	{
116		;
117	}
118	/* If we are running Solaris */
119	if (strcmp(un.sysname, "SunOS") == 0 )
120	{
121		;
122	}
123
124	output("This implementation is not tested yet\n");
125	output_fini();
126	return PTS_UNTESTED;
127}
128