2
0

working-directory.c 681 B

1234567891011121314151617181920212223242526272829
  1. #include <reproc/run.h>
  2. #include "assert.h"
  3. static void replace(char *string, char old, char new)
  4. {
  5. for (size_t i = 0; i < strlen(string); i++) {
  6. string[i] = (char) (string[i] == old ? new : string[i]);
  7. }
  8. }
  9. int main(void)
  10. {
  11. const char *argv[] = { RESOURCE_DIRECTORY "/working-directory", NULL };
  12. char *output = NULL;
  13. reproc_sink sink = reproc_sink_string(&output);
  14. int r = -1;
  15. r = reproc_run_ex(argv,
  16. (reproc_options){ .working_directory = RESOURCE_DIRECTORY },
  17. sink, sink);
  18. ASSERT_OK(r);
  19. ASSERT(output != NULL);
  20. replace(output, '\\', '/');
  21. ASSERT_EQ_STR(output, RESOURCE_DIRECTORY);
  22. reproc_free(output);
  23. }