mkdtemp.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017 CNRS
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu.h>
  17. #include <common/config.h>
  18. #include <common/utils.h>
  19. #include "../helper.h"
  20. #include <unistd.h>
  21. int do_test(char *(*func)(char *tmpl))
  22. {
  23. int ret;
  24. char dirname[128] = "/tmp/abcdef_XXXXXX";
  25. char *ptr;
  26. struct stat sb;
  27. ptr = func(dirname);
  28. FPRINTF(stderr, "Directory '%s' (res '%s')\n", dirname, ptr);
  29. // use stat
  30. ret = stat(dirname, &sb);
  31. if (ret != 0 || !S_ISDIR(sb.st_mode))
  32. {
  33. FPRINTF(stderr, "Directory '%s' has not been created\n", dirname);
  34. return 1;
  35. }
  36. ret = rmdir(dirname);
  37. STARPU_CHECK_RETURN_VALUE(ret, "rmdir '%s'\n", dirname);
  38. return ret;
  39. }
  40. int main(void)
  41. {
  42. int ret, ret2;
  43. ret = do_test(_starpu_mkdtemp);
  44. ret2 = do_test(_starpu_mkdtemp_internal);
  45. return ret + ret2;
  46. }