Skip to content
Snippets Groups Projects
Commit 6324ed94 authored by Marco A L Barbosa's avatar Marco A L Barbosa
Browse files

Add support for emscripten tests

parent 3c6a4f2d
No related branches found
No related tags found
No related merge requests found
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gcc \
git \
libc6-dev \
python \
xz-utils
COPY emscripten.sh /
RUN bash /emscripten.sh
ENV PATH=$PATH:/rust/bin
COPY emscripten-entry.sh /
ENTRYPOINT ["/emscripten-entry.sh"]
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gcc \
git \
libc6-dev \
python \
xz-utils
COPY emscripten.sh /
RUN bash /emscripten.sh
ENV PATH=$PATH:/rust/bin
COPY emscripten-entry.sh /
ENTRYPOINT ["/emscripten-entry.sh"]
#!/bin/bash
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
set -ex
source /emsdk-portable/emsdk_env.sh &> /dev/null
# emsdk-portable provides a node binary, but we need version 8 to run wasm
export PATH="/node-v8.0.0-linux-x64/bin:$PATH"
exec "$@"
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
set -ex
cd /
curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \
tar -xz
cd /emsdk-portable
./emsdk update
./emsdk install sdk-1.37.13-64bit
./emsdk activate sdk-1.37.13-64bit
# Compile and cache libc
source ./emsdk_env.sh
echo "main(){}" > a.c
HOME=/emsdk-portable/ emcc a.c
HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c
rm -f a.*
# Make emsdk usable by any user
cp /root/.emscripten /emsdk-portable
chmod a+rxw -R /emsdk-portable
# node 8 is required to run wasm
cd /
curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \
tar -xJ
......@@ -168,6 +168,10 @@ case "$TARGET" in
qemu-aarch64 -L /usr/aarch64-linux-gnu/ $CARGO_TARGET_DIR/$TARGET/debug/libc-test
;;
*-emscripten)
cd $CARGO_TARGET_DIR/$TARGET/debug/deps/ && node ../libc-test.js
;;
*-rumprun-netbsd)
rumprun-bake hw_virtio /tmp/libc-test.img $CARGO_TARGET_DIR/$TARGET/debug/libc-test
qemu-system-x86_64 -nographic -vga none -m 64 \
......
......@@ -13,7 +13,8 @@ fn main() {
let linux = target.contains("unknown-linux");
let android = target.contains("android");
let apple = target.contains("apple");
let musl = target.contains("musl");
let emscripten = target.contains("asm");
let musl = target.contains("musl") || emscripten;
let uclibc = target.contains("uclibc");
let freebsd = target.contains("freebsd");
let dragonfly = target.contains("dragonfly");
......@@ -25,7 +26,7 @@ fn main() {
let mut cfg = ctest::TestGenerator::new();
// Pull in extra goodies
if linux || android {
if linux || android || emscripten {
cfg.define("_GNU_SOURCE", None);
} else if netbsd {
cfg.define("_NETBSD_SOURCE", Some("1"));
......@@ -165,7 +166,7 @@ fn main() {
}
}
if linux {
if linux || emscripten {
cfg.header("mqueue.h");
cfg.header("ucontext.h");
cfg.header("sys/signalfd.h");
......@@ -183,7 +184,7 @@ fn main() {
cfg.header("shadow.h");
}
if linux || android {
if linux || android || emscripten {
cfg.header("malloc.h");
cfg.header("net/ethernet.h");
cfg.header("netpacket/packet.h");
......@@ -237,7 +238,7 @@ fn main() {
cfg.header("sys/ioctl_compat.h");
}
if linux || freebsd || dragonfly || netbsd || apple {
if linux || emscripten || freebsd || dragonfly || netbsd || apple {
if !uclibc {
cfg.header("aio.h");
}
......@@ -356,6 +357,9 @@ fn main() {
"FILE_ATTRIBUTE_INTEGRITY_STREAM" |
"ERROR_NOTHING_TO_TERMINATE" if mingw => true,
// not defined
"IUTF8" | "ENOATTR" | "EXTA" | "EXTB" if emscripten => true,
"SIG_IGN" => true, // sighandler_t weirdness
// types on musl are defined a little differently
......@@ -428,6 +432,34 @@ fn main() {
"prlimit" | "prlimit64" | // non-int in 2nd arg
"strerror_r" if linux => true, // actually xpg-something-or-other
// not defined or fails to link
"aio_cancel" | "aio_error" | "aio_fsync" | "aio_read" | "aio_read_write" | "aio_return"|
"aio_suspend" | "aio_write" | "clock_nanosleep" | "clone" | "daemon" | "endspent" |
"epoll_create" | "epoll_create1" | "epoll_ctl" | "epoll_pwait" | "epoll_wait" |
"eventfd" | "faccessat" | "fallocate" | "fgetxattr" | "flistxattr" | "fork" |
"forkpty" | "fremovexattr" | "fsetxattr" | "ftok" | "futimes" | "getdtablesize" |
"getgrgid" | "getgrnam" | "getgroups" | "getpgid" | "getpgrp" | "getpwnam_r" |
"getpwuid_r" | "getspent" | "getspnam" | "getxattr" | "initgroups" | "lgetxattr" |
"listxattr" | "llistxattr" | "lremovexattr" | "lsetxattr" | "lutimes" | "mount" |
"mq_close" | "mq_getattr" | "mq_open" | "mq_receive" | "mq_send" | "mq_setattr" |
"mq_unlink" | "msgctl" | "msgget" | "msgrcv" | "msgsnd" | "pclose" | "popen" |
"ppoll" | "prctl" | "prlimit" | "prlimit64" | "process_vm_readv" |
"process_vm_writev" | "pthread_atfork" | "pthread_attr_getguardsize" |
"pthread_kill" | "pthread_mutexattr_getpshared" | "pthread_mutex_timedlock" |
"pthread_sigmask" | "ptrace" | "quotactl" | "readahead" | "reboot" | "removexattr" |
"sched_getaffinity" | "sched_getparam" | "sched_get_priority_max" |
"sched_get_priority_min" | "sched_getscheduler" | "sched_rr_get_interval" |
"sched_setaffinity" | "sched_setparam" | "sched_setscheduler" | "sem_close" |
"semctl" | "semget" | "semop" | "sem_open" | "sem_timedwait" | "sem_unlink" |
"sendfile" | "setfsgid" | "setfsuid" | "setgroups" | "sethostname" | "setns" |
"setpgid" | "setpgrp" | "setspent" | "settimeofday" | "setxattr" | "shmat" |
"shmctl" | "shmdt" | "shmget" | "sigaltstack" | "signalfd" | "sigsuspend" |
"sigtimedwait" | "sigwait" | "sigwaitinfo" | "splice" | "sync_file_range" |
"syscall" | "sysinfo" | "tee" | "umount" | "umount2" | "unshare" | "vmsplice"
if emscripten => true,
// n if n.starts_with("epoll") && emscripten => true,
// int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that
// they match the interface defined by Linux verbatim, but they conflict with other
// send*/recv* syscalls
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment