Skip to content

Commit

Permalink
add test for chdir
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej committed Nov 12, 2024
1 parent 8dc9bc6 commit de638a1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/wasix/create-dir-at-cwd-with-chdir/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

// the difference between this test and the one in create-dir-at-cwd is the
// presence of chdir.

// this will force chdir to be linked with this binary which in turn will change
// the behavior of rel_path logic the libc.
//
// for more info see: libc-find-relpath.h in wasix-libc
int (*dummy_chdir_ref)(const char *path) = chdir;

int main() {
int status = EXIT_FAILURE;

const char *dirName1 = "test1";
if (mkdir(dirName1, 0755) != 0) {
goto end;
}

const char *dirName2 = "./test2";
if (mkdir(dirName2, 0755) != 0) {
goto end;
}

status = EXIT_SUCCESS;

end:
printf("%d", status);
return 0;
}
5 changes: 5 additions & 0 deletions tests/wasix/create-dir-at-cwd-with-chdir/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

$WASMER -q run main.wasm --dir . > output

rmdir test1 test2 2>/dev/null && printf "0" | diff -u output - 1>/dev/null

0 comments on commit de638a1

Please sign in to comment.