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.

91 lines
2.0 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <signal.h>
  4. #include <errno.h>
  5. #include <sys/wait.h>
  6. #include <unistd.h>
  7. #include <sys/stat.h>
  8. #include <fcntl.h>
  9. #include "tsttmp.h" // defines DbgPrint as printf
  10. extern int errno;
  11. VOID rmdir0(char *);
  12. //
  13. // 'tstrmdir dirname'.
  14. //
  15. // The directory /psx/test is used as the base directory. It is assumed
  16. // to have the following sub directories:
  17. // rmtst1 containing one file "ab"
  18. // rmtst2 containing one file ".a" (??)
  19. // rmtst3 containing one file "a."
  20. // rmtst4 containing one file "abcde"
  21. // /psx/test must not have an existing subdirectory with the same name as
  22. // the dir argument.
  23. //
  24. int
  25. main(int argc, char *argv[])
  26. {
  27. if (argc != 2) {
  28. DbgPrint("Usage: 'tstrmdir dirname'\n");
  29. return 1;
  30. }
  31. rmdir0(argv[1]);
  32. return 1;
  33. }
  34. VOID
  35. rmdir0(char *f)
  36. {
  37. int rc;
  38. DbgPrint("rmdir0:++ %s\n",f);
  39. DbgPrint("chdir to /psx/test\n");
  40. rc = chdir("/psx/test");
  41. ASSERT(rc != -1);
  42. if (rc == -1)
  43. DbgPrint("chdir errno = %d\n", errno);
  44. //
  45. // Test deleting an empty directory
  46. //
  47. DbgPrint("mkdir %s\n", f);
  48. rc = mkdir(f, 0);
  49. ASSERT(rc != -1);
  50. if (rc == -1)
  51. DbgPrint("mkdir errno = %d\n", errno);
  52. DbgPrint("Testing removal of empty directory %s\n", f);
  53. rc = rmdir(f);
  54. ASSERT(rc != -1);
  55. if (rc == -1)
  56. DbgPrint("rmdir errno = %d\n", errno);
  57. DbgPrint("Testing removal of nonexistent directory %s\n", f);
  58. rc = rmdir(f);
  59. ASSERT(rc == -1 && errno == ENOENT);
  60. DbgPrint("Testing removal of 'rmtst1' - with one entry 'ab'\n");
  61. rc = rmdir("rmtst1");
  62. ASSERT(rc == -1 && errno == ENOTEMPTY);
  63. // DbgPrint("Testing removal of 'rmtst2' with one entry '.a'\n");
  64. // rc = rmdir("rmtst2");
  65. // ASSERT(rc == -1 && errno == ENOTEMPTY);
  66. DbgPrint("Testing removal of 'rmtst3' with one entry 'a.'\n");
  67. rc = rmdir("rmtst3");
  68. ASSERT(rc == -1 && errno == ENOTEMPTY);
  69. DbgPrint("Testing removal of 'rmtst4' with one entry 'abcde' \n");
  70. rc = rmdir("rmtst4");
  71. ASSERT(rc == -1 && errno == ENOTEMPTY);
  72. DbgPrint("rmdir0:--\n");
  73. }