Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
5.6 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <signal.h>
  4. #include <errno.h>
  5. #include <unistd.h>
  6. #include <limits.h>
  7. #include <fcntl.h>
  8. #include <stdio.h>
  9. #include <sys/wait.h>
  10. #include <sys/utsname.h>
  11. #include <sys/times.h>
  12. #include "tsttmp.h" // defines DbgPrint as printf
  13. extern int errno;
  14. VOID sysconf0(void);
  15. VOID pathconf0(void);
  16. VOID fpathconf0(void);
  17. VOID uname0(void);
  18. VOID time0(void);
  19. //
  20. // 'tstmisc'
  21. // tests sysconf(), pathconf(), fpathconf(), uname(), time(), times()
  22. // The file /psx/test/conffile should exist
  23. //
  24. int
  25. __cdecl
  26. main(int argc, char *argv[])
  27. {
  28. if (argc != 1) {
  29. DbgPrint("Usage: '%s'\n", argv[0]);
  30. return 1;
  31. }
  32. sysconf0();
  33. pathconf0();
  34. fpathconf0();
  35. uname0();
  36. time0();
  37. return 1;
  38. }
  39. VOID
  40. sysconf0(void)
  41. {
  42. BOOLEAN fail = FALSE;
  43. DbgPrint("sysconf0:++\n");
  44. if (sysconf(_SC_ARG_MAX) != ARG_MAX) {
  45. DbgPrint("sysconf FAIL on ARG_MAX\n");
  46. fail = TRUE;
  47. }
  48. if (sysconf(_SC_CHILD_MAX) != CHILD_MAX) {
  49. DbgPrint("sysconf FAIL on CHILD_MAX\n");
  50. fail = TRUE;
  51. }
  52. if (sysconf(_SC_CLK_TCK) != CLK_TCK) {
  53. DbgPrint("sysconf FAIL on CLK_TCK\n");
  54. fail = TRUE;
  55. }
  56. if (sysconf(_SC_NGROUPS_MAX) != NGROUPS_MAX) {
  57. DbgPrint("sysconf FAIL on NGROUPS_MAX\n");
  58. fail = TRUE;
  59. }
  60. if (sysconf(_SC_OPEN_MAX) != OPEN_MAX) {
  61. DbgPrint("sysconf FAIL on OPEN_MAX\n");
  62. fail = TRUE;
  63. }
  64. if (sysconf(_SC_JOB_CONTROL) == 0L)
  65. DbgPrint("sysconf JOB_CONTROL OFF\n");
  66. else
  67. DbgPrint("sysconf JOB_CONTROL ON\n");
  68. if (sysconf(_SC_SAVED_IDS) == 0L)
  69. DbgPrint("sysconf SAVED_IDS OFF\n");
  70. else
  71. DbgPrint("sysconf SAVED_IDS ON\n");
  72. DbgPrint("sysconf VERSION = %d\n", sysconf(_SC_VERSION));
  73. if (!fail)
  74. DbgPrint("sysconf PASSED\n");
  75. DbgPrint("sysconf0:--\n");
  76. }
  77. VOID pathconf0(void)
  78. {
  79. BOOLEAN fail = FALSE;
  80. DbgPrint("pathconf0:++\n");
  81. if (pathconf("/psx/test/conffile", _PC_LINK_MAX) != LINK_MAX) {
  82. DbgPrint("pathconf FAIL on LINK_MAX\n");
  83. fail = TRUE;
  84. }
  85. if (pathconf("/psx/test/conffile", _PC_MAX_CANON) != MAX_CANON) {
  86. DbgPrint("pathconf FAIL on MAX_CANON\n");
  87. fail = TRUE;
  88. }
  89. if (pathconf("/psx/test/conffile", _PC_MAX_INPUT) != MAX_INPUT) {
  90. DbgPrint("pathconf FAIL on MAX_INPUT\n");
  91. fail = TRUE;
  92. }
  93. if (pathconf("/psx/test/conffile", _PC_NAME_MAX) != NAME_MAX) {
  94. DbgPrint("pathconf FAIL on NAME_MAX\n");
  95. fail = TRUE;
  96. }
  97. if (pathconf("/psx/test/conffile", _PC_PATH_MAX) != PATH_MAX) {
  98. DbgPrint("pathconf FAIL on PATH_MAX\n");
  99. fail = TRUE;
  100. }
  101. if (pathconf("/psx/test/conffile", _PC_PIPE_BUF) != PIPE_BUF) {
  102. DbgPrint("pathconf FAIL on PIPE_BUF\n");
  103. fail = TRUE;
  104. }
  105. if (pathconf("/psx/test/conffile", _PC_CHOWN_RESTRICTED) == 0L)
  106. DbgPrint("pathconf CHOWN_RESTRICTED OFF\n");
  107. else
  108. DbgPrint("pathconf CHOWN_RESTRICTED ON\n");
  109. if (pathconf("/psx/test/conffile", _PC_NO_TRUNC) == 0L)
  110. DbgPrint("pathconf NO_TRUNC OFF\n");
  111. else
  112. DbgPrint("pathconf NO_TRUNC ON\n");
  113. if (pathconf("/psx/test/conffile", _PC_VDISABLE) == 0L)
  114. DbgPrint("pathconf VDISABLE OFF\n");
  115. else
  116. DbgPrint("pathconf VDISABLE ON\n");
  117. if (!fail)
  118. DbgPrint("pathconf PASSED\n");
  119. DbgPrint("pathconf0:--\n");
  120. }
  121. VOID fpathconf0(void)
  122. {
  123. BOOLEAN fail = FALSE;
  124. int fd;
  125. DbgPrint("fpathconf0:++\n");
  126. if ( (fd = open("/psx/test/conffile", O_RDONLY)) == -1) {
  127. DbgPrint("Cannot open /psx/test/conffile\n");
  128. return;
  129. }
  130. if (fpathconf(fd, _PC_LINK_MAX) != LINK_MAX) {
  131. DbgPrint("fpathconf FAIL on LINK_MAX\n");
  132. fail = TRUE;
  133. }
  134. if (fpathconf(fd, _PC_MAX_CANON) != MAX_CANON) {
  135. DbgPrint("fpathconf FAIL on MAX_CANON\n");
  136. fail = TRUE;
  137. }
  138. if (fpathconf(fd, _PC_MAX_INPUT) != MAX_INPUT) {
  139. DbgPrint("fpathconf FAIL on MAX_INPUT\n");
  140. fail = TRUE;
  141. }
  142. if (fpathconf(fd, _PC_NAME_MAX) != NAME_MAX) {
  143. DbgPrint("fpathconf FAIL on NAME_MAX\n");
  144. fail = TRUE;
  145. }
  146. if (fpathconf(fd, _PC_PATH_MAX) != PATH_MAX) {
  147. DbgPrint("fpathconf FAIL on PATH_MAX\n");
  148. fail = TRUE;
  149. }
  150. if (fpathconf(fd, _PC_PIPE_BUF) != PIPE_BUF) {
  151. DbgPrint("fpathconf FAIL on PIPE_BUF\n");
  152. fail = TRUE;
  153. }
  154. if (fpathconf(fd, _PC_CHOWN_RESTRICTED) == 0L)
  155. DbgPrint("fpathconf CHOWN_RESTRICTED OFF\n");
  156. else
  157. DbgPrint("fpathconf CHOWN_RESTRICTED ON\n");
  158. if (fpathconf(fd, _PC_NO_TRUNC) == 0L)
  159. DbgPrint("fpathconf NO_TRUNC OFF\n");
  160. else
  161. DbgPrint("fpathconf NO_TRUNC ON\n");
  162. if (fpathconf(fd, _PC_VDISABLE) == 0L)
  163. DbgPrint("fpathconf VDISABLE OFF\n");
  164. else
  165. DbgPrint("fpathconf VDISABLE ON\n");
  166. if (!fail)
  167. DbgPrint("fpathconf PASSED\n");
  168. DbgPrint("fpathconf0:--\n");
  169. }
  170. VOID uname0(void)
  171. {
  172. struct utsname name;
  173. int rc;
  174. DbgPrint("uname0:++\n");
  175. rc = uname((struct utsname *) &name);
  176. if (rc == -1) {
  177. DbgPrint("FAIL call to uname, errno = %d.\n", errno);
  178. }
  179. else {
  180. DbgPrint("sysname = %s\nnodename = %s(should be null)\nrelease = %s\nversion = %s\nmachine = %s\n",
  181. name.sysname, name.nodename, name.release, name.version,
  182. name.machine);
  183. }
  184. DbgPrint("uname0:--\n");
  185. }
  186. // This should translate to yy mm dd format
  187. VOID time0(void)
  188. {
  189. time_t tloc;
  190. time_t rc;
  191. DbgPrint("time0:++\n");
  192. rc = time((time_t *) &tloc);
  193. ASSERT(rc == tloc);
  194. DbgPrint("Seconds since the Epoch = %ld\n", tloc);
  195. DbgPrint("time0:--\n");
  196. }
  197. VOID time1(void)
  198. {
  199. struct tms tbuf;
  200. clock_t rc;
  201. DbgPrint("time1:++\n");
  202. rc = times((struct tms *) &tbuf);
  203. DbgPrint("stime = %ld, utime = %ld, cstime = %ld, cutime = %ld rc = %ld\n",
  204. tbuf.tms_stime, tbuf.tms_utime,tbuf.tms_cstime,tbuf.tms_cutime,rc);
  205. DbgPrint("time1:--\n");
  206. }