Skip to content

Commit

Permalink
integration test: attach a test directory to test file system (#61)
Browse files Browse the repository at this point in the history
* integration test: attach a test directory to test file system

* change lwip version

* build-fs.sh: replace llvm-objcopy with objcopy
  • Loading branch information
saza-ku authored Apr 11, 2024
1 parent dc59c77 commit 33214ac
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
22 changes: 11 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ const BuildParams = struct {
fn new(b: *Build) Self {
var params = BuildParams{};

const test_option = b.option(bool, "test", "run tests");
if (test_option) |t| {
params.is_test = t;
if (t) {
createTestDir() catch unreachable;
params.dir_path = TEST_DIR_PATH;
}
} else {
params.is_test = false;
}

const obj_path_option = b.option([]const u8, "app-obj", "object file of application");
if (obj_path_option) |p| {
params.obj_path = p;
Expand All @@ -50,6 +39,17 @@ const BuildParams = struct {
params.dir_path = null;
}

const test_option = b.option(bool, "test", "run tests");
if (test_option) |t| {
params.is_test = t;
if (t) {
createTestDir() catch unreachable;
params.dir_path = TEST_DIR_PATH;
}
} else {
params.is_test = false;
}

return params;
}

Expand Down
9 changes: 1 addition & 8 deletions scripts/build-fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ mkdir -p build
tar -cf build/disk.tar --format=ustar -C $dir_path .
echo "tar archive created"

# check if llvm-objcopy is installed
if ! command -v llvm-objcopy &> /dev/null
then
echo "llvm-objcopy could not be found"
exit 1
fi

# convert the archive to binary
llvm-objcopy -Ibinary -Oelf64-x86-64 build/disk.tar build/disk.o
objcopy -Ibinary -Oelf64-x86-64 build/disk.tar build/disk.o
echo "disk.o created"
1 change: 1 addition & 0 deletions src/fs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ fn oct2int(oct: []const u8, len: usize) u32 {
pub fn init() void {
// check if fs is enabled
if (!options.has_fs) {
log.debug.print("file system is not attached\n");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/wasi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ fn testServerSocket(base: usize) bool {
log.fatal.printf("sock_open failed: res={d}\n", .{@intFromEnum(res)});
return false;
}
if (!(fd1.* == 4)) {
if (!(fd1.* == 5)) {
log.fatal.printf("sock_open failed: fd={d}\n", .{fd1.*});
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/lwip
Submodule lwip updated from d0efd9 to 1cc153

0 comments on commit 33214ac

Please sign in to comment.