Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests, run on CI #92

Merged
merged 5 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,25 @@ jobs:
working-directory: ./w2c2
run: make BUILD=${{ matrix.build }} FEATURES="unistd libgen getopt glob ${{ matrix.threads && 'threads' || '' }}"

- if: steps.changes.outputs.w2c2 == 'true'
name: Test w2c2
env:
LDFLAGS: -static
working-directory: ./w2c2
run: make test BUILD=${{ matrix.build }} FEATURES="unistd libgen getopt glob ${{ matrix.threads && 'threads' || '' }}"

- if: steps.changes.outputs.w2c2 == 'true'
name: Build futex
working-directory: ./futex
run: make BUILD=${{ matrix.build }}

- if: steps.changes.outputs.w2c2 == 'true'
name: Test futex
env:
LDFLAGS: -static ${{ matrix.system.linkAtomic && '-latomic' || '' }}
working-directory: ./futex
run: make test BUILD=${{ matrix.build }}

- if: steps.changes.outputs.w2c2 == 'true'
name: Run WebAssembly tests
env:
Expand All @@ -104,9 +118,15 @@ jobs:
working-directory: ./wasi
run: make BUILD=${{ matrix.build }}

- if: steps.changes.outputs.wasi == 'true'
name: Test wasi
env:
LDFLAGS: -static ${{ matrix.system.linkAtomic && '-latomic' || '' }}
working-directory: ./wasi
run: make test BUILD=${{ matrix.build }}
macos:
runs-on: macos-latest
name: "macOS, ${{ matrix.system.target }} (build=${{ matrix.build }}, threads=${{ matrix.threads }})"
name: "macOS (build=${{ matrix.build }}, threads=${{ matrix.threads }})"

strategy:
fail-fast: false
Expand All @@ -133,15 +153,23 @@ jobs:
working-directory: ./w2c2
run: make BUILD=${{ matrix.build }} FEATURES="unistd libgen getopt glob ${{ matrix.threads && 'threads' || '' }}"

- if: steps.changes.outputs.w2c2 == 'true'
name: Test w2c2
working-directory: ./w2c2
run: make test BUILD=${{ matrix.build }} FEATURES="unistd libgen getopt glob ${{ matrix.threads && 'threads' || '' }}"

- if: steps.changes.outputs.w2c2 == 'true'
name: Build futex
working-directory: ./futex
run: make BUILD=${{ matrix.build }}

- if: steps.changes.outputs.w2c2 == 'true'
name: Test futex
working-directory: ./futex
run: make test BUILD=${{ matrix.build }}

- if: steps.changes.outputs.w2c2 == 'true'
name: Run WebAssembly tests
env:
ARCH: ${{ matrix.system.target }}
working-directory: ./tests
shell: bash
run: make run-tests
Expand All @@ -151,6 +179,11 @@ jobs:
working-directory: ./wasi
run: make BUILD=${{ matrix.build }} FEATURES="unistd sysuio systime sysresource strndup fcntl timespec lstat pthreads"

- if: steps.changes.outputs.wasi == 'true'
name: Test wasi
working-directory: ./wasi
run: make test BUILD=${{ matrix.build }} FEATURES="unistd sysuio systime sysresource strndup fcntl timespec lstat pthreads"

windows-msvc:
runs-on: windows-2019
name: "Windows (MSVC)"
Expand Down
8 changes: 6 additions & 2 deletions futex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ libw2c2futex.a: $(TARGET_OBJECTS)
$(AR) qc $@ $^
ranlib $@

test: $(TEST_OBJECTS)
futex_test: $(TEST_OBJECTS)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)

.PHONY: test
test: futex_test
./futex_test

clean:
-rm -f *.o *.a
-rm -f test
-rm -f futex_test
8 changes: 4 additions & 4 deletions futex/futex_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ testFutex(void) {

if (!WASM_THREAD_CREATE(&thread1, testThreadFunc, &arg1)) {
fprintf(stderr, "FAIL testFutex: failed to create thread1\n");
return;
exit(1);
}

if (!WASM_THREAD_CREATE(&thread2, testThreadFunc, &arg2)) {
fprintf(stderr, "FAIL testFutex: failed to create thread2\n");
return;
exit(1);
}

if (!WASM_THREAD_CREATE(&thread3, testThreadFunc, &arg3)) {
fprintf(stderr, "FAIL testFutex: failed to create thread3\n");
return;
exit(1);
}

if (!WASM_THREAD_CREATE(&thread4, testThreadFunc, &arg4)) {
fprintf(stderr, "FAIL testFutex: failed to create thread4\n");
return;
exit(1);
}

/* Wait for all threads to have started */
Expand Down
59 changes: 30 additions & 29 deletions futex/list_test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>

#include "list_test.h"
#include "list.h"
Expand Down Expand Up @@ -34,23 +35,23 @@ testListOperations(void) {

if (list != &element2.link) {
fprintf(stderr, "FAIL testList: list != &element2.link\n");
return;
exit(1);
}
if (list->next != &element3.link) {
fprintf(stderr, "FAIL testList: list->next != &element3.link\n");
return;
exit(1);
}
if (list->prev != NULL) {
fprintf(stderr, "FAIL testList: list->prev != NULL\n");
return;
exit(1);
}
if (element3.link.next != NULL) {
fprintf(stderr, "FAIL testList: element3.link.next != NULL\n");
return;
exit(1);
}
if (element3.link.prev != &element2.link) {
fprintf(stderr, "FAIL testList: element3.link.prev != &element2.link\n");
return;
exit(1);
}

/*Prepend element1 to the list. */
Expand All @@ -59,31 +60,31 @@ testListOperations(void) {

if (list != &element1.link) {
fprintf(stderr, "FAIL testList: list != &element1.link\n");
return;
exit(1);
}
if (list->next != &element2.link) {
fprintf(stderr, "FAIL testList: list->next != &element2.link\n");
return;
exit(1);
}
if (list->prev != NULL) {
fprintf(stderr, "FAIL testList: list->prev != NULL\n");
return;
exit(1);
}
if (element2.link.next != &element3.link) {
fprintf(stderr, "FAIL testList: element2.link.next != &element3.link\n");
return;
exit(1);
}
if (element2.link.prev != &element1.link) {
fprintf(stderr, "FAIL testList: element2.link.prev != &element1.link\n");
return;
exit(1);
}
if (element3.link.next != NULL) {
fprintf(stderr, "FAIL testList: element3.link.next != NULL\n");
return;
exit(1);
}
if (element3.link.prev != &element2.link) {
fprintf(stderr, "FAIL testList: element3.link.prev != &element2.link\n");
return;
exit(1);
}

/* Remove element2 from the list. */
Expand All @@ -92,31 +93,31 @@ testListOperations(void) {

if (list != &element1.link) {
fprintf(stderr, "FAIL testList: list != &element1.link\n");
return;
exit(1);
}
if (list->next != &element3.link) {
fprintf(stderr, "FAIL testList: list->next != &element3.link\n");
return;
exit(1);
}
if (list->prev != NULL) {
fprintf(stderr, "FAIL testList: list->prev != NULL\n");
return;
exit(1);
}
if (element2.link.next != NULL) {
fprintf(stderr, "FAIL testList: element2.link.next != NULL\n");
return;
exit(1);
}
if (element2.link.prev != NULL) {
fprintf(stderr, "FAIL testList: element2.link.prev != NULL\n");
return;
exit(1);
}
if (element3.link.next != NULL) {
fprintf(stderr, "FAIL testList: element3.link.next != NULL\n");
return;
exit(1);
}
if (element3.link.prev != &element1.link) {
fprintf(stderr, "FAIL testList: element3.link.prev != &element1.link\n");
return;
exit(1);
}

/* Remove element1 from the list. */
Expand All @@ -125,23 +126,23 @@ testListOperations(void) {

if (list != &element3.link) {
fprintf(stderr, "FAIL testList: list != &element3.link\n");
return;
exit(1);
}
if (list->next != NULL) {
fprintf(stderr, "FAIL testList: list->next != NULL\n");
return;
exit(1);
}
if (list->prev != NULL) {
fprintf(stderr, "FAIL testList: list->prev != NULL\n");
return;
exit(1);
}
if (element1.link.next != NULL) {
fprintf(stderr, "FAIL testList: element1.link.next != NULL\n");
return;
exit(1);
}
if (element1.link.prev != NULL) {
fprintf(stderr, "FAIL testList: element1.link.prev != NULL\n");
return;
exit(1);
}

fprintf(stderr, "PASS testList\n");
Expand All @@ -158,24 +159,24 @@ testFreeLink(ListLink* link) {
case 0:
if (element->value != 1) {
fprintf(stderr, "FAIL testListFree: element->value != 1\n");
return;
exit(1);
}
break;
case 1:
if (element->value != 2) {
fprintf(stderr, "FAIL testListFree: element->value != 2\n");
return;
exit(1);
}
break;
case 2:
if (element->value != 3) {
fprintf(stderr, "FAIL testListFree: element->value != 3\n");
return;
exit(1);
}
break;
default:
fprintf(stderr, "FAIL testListFree: freeCount > 2\n");
return;
exit(1);
}

freeCount++;
Expand Down Expand Up @@ -217,7 +218,7 @@ testListFree(void) {

if (freeCount != 3) {
fprintf(stderr, "FAIL testListFree: freeCount != 3\n");
return;
exit(1);
}

fprintf(stderr, "PASS testListFree\n");
Expand Down
Loading
Loading