mkdtemp.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. int do_test(char *(*func)(char *tmpl))
  21. {
  22. int ret;
  23. char dirname[128] = "/tmp/abcdef_XXXXXX";
  24. char *ptr;
  25. struct stat sb;
  26. ptr = func(dirname);
  27. FPRINTF(stderr, "Directory '%s' (res '%s')\n", dirname, ptr);
  28. // use stat
  29. ret = stat(dirname, &sb);
  30. if (ret != 0 || !S_ISDIR(sb.st_mode))
  31. {
  32. FPRINTF(stderr, "Directory '%s' has not been created\n", dirname);
  33. return 1;
  34. }
  35. ret = rmdir(dirname);
  36. STARPU_CHECK_RETURN_VALUE(ret, "rmdir '%s'\n", dirname);
  37. return ret;
  38. }
  39. int main(void)
  40. {
  41. int ret, ret2;
  42. ret = do_test(_starpu_mkdtemp);
  43. ret2 = do_test(_starpu_mkdtemp_internal);
  44. return ret + ret2;
  45. }