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.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17
18 * This sample test aims to check the following assertion:
19 * The function fails and return EPERM if caller has not the
20 * privilege to perform the operation.
21
22 * The steps are:
23 * -> if this implementation does not support privileges, return PTS_UNSUPPORTED
24 * -> Otherwise, use the implementation features to come to a situation where
25 * pthread_mutex_init should fail because of the privileges, and then check
26 * that the return code is EPERM.
27 * -> return PTS_UNTESTED if the architecture is not present in the test.
28 */
29
30
31 /********************************************************************************************/
32 /****************************** standard includes *****************************************/
33 /********************************************************************************************/
34 #include <pthread.h>
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <stdlib.h>
38 #include <errno.h>
39 #include <stdarg.h>
40 #include <sys/utsname.h>
41 #include <string.h>
42
43 /********************************************************************************************/
44 /****************************** Test framework *****************************************/
45 /********************************************************************************************/
46 #include "../../testfrmw/testfrmw.h"
47 #include "../../testfrmw/testfrmw.c"
48 /* This header is responsible for defining the following macros:
49 * UNRESOLVED(ret, descr);
50 * where descr is a description of the error and ret is an int (error code for example)
51 * FAILED(descr);
52 * where descr is a short text saying why the test has failed.
53 * PASSED();
54 * No parameter.
55 *
56 * Both three macros shall terminate the calling process.
57 * The testcase shall not terminate in any other maneer.
58 *
59 * The other file defines the functions
60 * void output_init()
61 * void output(char * string, ...)
62 *
63 * Those may be used to output information.
64 */
65
66 /********************************************************************************************/
67 /********************************** Configuration ******************************************/
68 /********************************************************************************************/
69 #ifndef VERBOSE
70 #define VERBOSE 1
71 #endif
72
73 #ifndef PTS_UNSUPPORTED
74 #define PTS_UNSUPPORTED 4
75 #endif
76 #ifndef PTS_UNTESTED
77 #define PTS_UNTESTED 5
78 #endif
79
80 /********************************************************************************************/
81 /*********************************** Test case *****************************************/
82 /********************************************************************************************/
main(void)83 int main(void)
84 {
85 int ret;
86 struct utsname un;
87
88 output_init();
89 ret = uname(&un);
90 if (ret == -1) {
91 UNRESOLVED(errno, "Unable to get Implementation name");
92 }
93 #if VERBOSE > 0
94 output("Implementation is: \n\t%s\n\t%s\n\t%s\n", un.sysname,
95 un.release, un.version);
96 #endif
97
98 /* If we are running Linux */
99 if (strcmp(un.sysname, "Linux") == 0) {
100 /* Linux does not provide privilege access to pthread_mutex_init function */
101 ret = PTS_UNSUPPORTED;
102 output("Linux does not provide this feature\n");
103 output_fini();
104 return ret;
105 }
106
107 /* If we are running AIX */
108 if (strcmp(un.sysname, "AIX") == 0) {
109 ;
110 }
111 /* If we are running Solaris */
112 if (strcmp(un.sysname, "SunOS") == 0) {
113 ;
114 }
115
116 output("This implementation is not tested yet\n");
117 output_fini();
118 return PTS_UNTESTED;
119 }
120