diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/wasm | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/wasm')
-rw-r--r-- | meson/test cases/wasm/1 basic/hello.c | 7 | ||||
-rw-r--r-- | meson/test cases/wasm/1 basic/hello.cpp | 7 | ||||
-rw-r--r-- | meson/test cases/wasm/1 basic/hello.html | 8 | ||||
-rw-r--r-- | meson/test cases/wasm/1 basic/meson.build | 4 | ||||
-rw-r--r-- | meson/test cases/wasm/2 threads/meson.build | 10 | ||||
-rw-r--r-- | meson/test cases/wasm/2 threads/threads.c | 21 | ||||
-rw-r--r-- | meson/test cases/wasm/2 threads/threads.cpp | 13 |
7 files changed, 70 insertions, 0 deletions
diff --git a/meson/test cases/wasm/1 basic/hello.c b/meson/test cases/wasm/1 basic/hello.c new file mode 100644 index 000000000..a104b3780 --- /dev/null +++ b/meson/test cases/wasm/1 basic/hello.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() { + printf("Hello World\n"); + return 0; +} + diff --git a/meson/test cases/wasm/1 basic/hello.cpp b/meson/test cases/wasm/1 basic/hello.cpp new file mode 100644 index 000000000..119dc8b9f --- /dev/null +++ b/meson/test cases/wasm/1 basic/hello.cpp @@ -0,0 +1,7 @@ +#include<iostream> + +int main(void) { + std::cout << "Hello World" << std::endl; + return 0; +} + diff --git a/meson/test cases/wasm/1 basic/hello.html b/meson/test cases/wasm/1 basic/hello.html new file mode 100644 index 000000000..637bc2074 --- /dev/null +++ b/meson/test cases/wasm/1 basic/hello.html @@ -0,0 +1,8 @@ +<html> + <head> + <meta charset="utf-8"> + </head> + <body> + <script src="hello.js"></script> + </body> +</html> diff --git a/meson/test cases/wasm/1 basic/meson.build b/meson/test cases/wasm/1 basic/meson.build new file mode 100644 index 000000000..1092a9ba7 --- /dev/null +++ b/meson/test cases/wasm/1 basic/meson.build @@ -0,0 +1,4 @@ +project('emcctest', 'c', 'cpp') + +executable('hello-c', 'hello.c') +executable('hello', 'hello.cpp') diff --git a/meson/test cases/wasm/2 threads/meson.build b/meson/test cases/wasm/2 threads/meson.build new file mode 100644 index 000000000..cb682b877 --- /dev/null +++ b/meson/test cases/wasm/2 threads/meson.build @@ -0,0 +1,10 @@ +project( + 'threads', + 'c', 'cpp', + default_options : ['cpp_std=c++11'], +) + +dep_threads = dependency('threads') + +executable('threads-c', 'threads.c', dependencies : dep_threads) +executable('threads-c++', 'threads.cpp', dependencies : dep_threads) diff --git a/meson/test cases/wasm/2 threads/threads.c b/meson/test cases/wasm/2 threads/threads.c new file mode 100644 index 000000000..e79bff170 --- /dev/null +++ b/meson/test cases/wasm/2 threads/threads.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <unistd.h> +#include <pthread.h> + +void inthread(void * args) { + sleep(1); + printf("In thread\n"); +} + +int main() { +#ifdef __EMSCRIPTEN_PTHREADS__ + pthread_t thread_id; + printf("Before Thread\n"); + pthread_create(&thread_id, NULL, (void *)*inthread, NULL); + pthread_join(thread_id, NULL); + printf("After Thread\n"); + return 0; +#else +# error "threads not enabled\n" +#endif +} diff --git a/meson/test cases/wasm/2 threads/threads.cpp b/meson/test cases/wasm/2 threads/threads.cpp new file mode 100644 index 000000000..1caa73da3 --- /dev/null +++ b/meson/test cases/wasm/2 threads/threads.cpp @@ -0,0 +1,13 @@ +#include <unistd.h> +#include <iostream> +#include <thread> + +int main(void) { + std::cout << "Before thread" << std::endl; + std::thread t([]() { + sleep(1); + std::cout << "In a thread." << std::endl; + }); + t.join(); + std::cout << "After thread" << std::endl; +} |