fchdir.c 411 B

1234567891011121314151617181920
  1. #include <unistd.h>
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "test_helpers.h"
  6. int main(void) {
  7. int fd = open("..", O_DIRECTORY);
  8. ERROR_IF(open, fd, == -1);
  9. UNEXP_IF(open, fd, < 0);
  10. int status = fchdir(fd);
  11. ERROR_IF(fchdir, status, == -1);
  12. UNEXP_IF(fchdir, status, != 0);
  13. int c = close(fd);
  14. ERROR_IF(close, c, == -1);
  15. UNEXP_IF(close, c, != 0);
  16. }