Commit 186b72c5 authored by qinsoon's avatar qinsoon

tests runs on linux

also fixed a bug related with exception block label
parent 13f6aae3
Pipeline #16 canceled with stage
in 34 seconds
#!/bin/bash
echo "rsync source to machine: $1..."
rsync -avz --exclude 'Cargo.lock' --exclude '*.log' --exclude 'emit*' --exclude 'target*' --exclude '.git' . $1:~/mu/
echo "executing tests..."
ssh $1 "cd ~/mu; ./run_test.sh $2"
#!/bin/sh
#!/bin/bash
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test "$@"
echo "Note: this script is only for the convenience of running tests in our lab. "
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
# detect OS
OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`
if [ "{$OS}" == "windowsnt" ]; then
OS=windows
elif [ "{$OS}" == "darwin" ]; then
OS=mac
else
OS=`uname`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
fi
OS=`lowercase $OS`
DistroBasedOn=`lowercase $DistroBasedOn`
readonly OS
readonly DIST
readonly DistroBasedOn
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi
fi
echo "---------"
echo "OS: $OS"
echo "KERNEL: $KERNEL"
echo "ARCH: $MACH"
echo "---------"
if [ "$OS" == "linux" ]; then
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CLANG_FOR_AOT=clang-3.8 cargo test "$@"
elif [ "$OS" == "Darwin" ]; then
RUSTFLAGS=-Zincremental=target/incr-cache RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test "$@"
else
echo "unknown OS. do not use this script to run"
fi
......@@ -967,8 +967,8 @@ impl ASMCodeGen {
}
}
fn asm_block_label(&self, label: MuName) -> String {
symbol(format!("{}_{}", self.cur().name, label))
fn mangle_block_label(&self, label: MuName) -> String {
format!("{}_{}", self.cur().name, label)
}
fn control_flow_analysis(&mut self) {
......@@ -1127,7 +1127,7 @@ impl CodeGenerator for ASMCodeGen {
}
fn start_block(&mut self, block_name: MuName) {
let label = format!("{}:", self.asm_block_label(block_name.clone()));
let label = format!("{}:", symbol(self.mangle_block_label(block_name.clone())));
self.add_asm_block_label(label, block_name.clone());
self.cur_mut().blocks.insert(block_name.clone(), ASMBlock::new());
......@@ -1136,13 +1136,12 @@ impl CodeGenerator for ASMCodeGen {
}
fn start_exception_block(&mut self, block_name: MuName) -> ValueLocation {
let block = self.asm_block_label(block_name.clone());
self.add_asm_symbolic(directive_globl(symbol(block.clone())));
self.add_asm_symbolic(format!("{}:", symbol(block.clone())));
self.start_block(block_name);
let mangled_name = self.mangle_block_label(block_name.clone());
self.add_asm_symbolic(directive_globl(symbol(mangled_name.clone())));
self.start_block(block_name.clone());
ValueLocation::Relocatable(RegGroup::GPR, block)
ValueLocation::Relocatable(RegGroup::GPR, mangled_name)
}
fn end_block(&mut self, block_name: MuName) {
......@@ -1646,77 +1645,77 @@ impl CodeGenerator for ASMCodeGen {
trace!("emit: jmp {}", dest_name);
// symbolic label, we dont need to patch it
let asm = format!("jmp {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jmp {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch(asm, dest_name)
}
fn emit_je(&mut self, dest_name: MuName) {
trace!("emit: je {}", dest_name);
let asm = format!("je {}", self.asm_block_label(dest_name.clone()));
let asm = format!("je {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jne(&mut self, dest_name: MuName) {
trace!("emit: jne {}", dest_name);
let asm = format!("jne {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jne {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_ja(&mut self, dest_name: MuName) {
trace!("emit: ja {}", dest_name);
let asm = format!("ja {}", self.asm_block_label(dest_name.clone()));
let asm = format!("ja {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jae(&mut self, dest_name: MuName) {
trace!("emit: jae {}", dest_name);
let asm = format!("jae {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jae {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jb(&mut self, dest_name: MuName) {
trace!("emit: jb {}", dest_name);
let asm = format!("jb {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jb {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jbe(&mut self, dest_name: MuName) {
trace!("emit: jbe {}", dest_name);
let asm = format!("jbe {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jbe {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jg(&mut self, dest_name: MuName) {
trace!("emit: jg {}", dest_name);
let asm = format!("jg {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jg {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jge(&mut self, dest_name: MuName) {
trace!("emit: jge {}", dest_name);
let asm = format!("jge {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jge {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jl(&mut self, dest_name: MuName) {
trace!("emit: jl {}", dest_name);
let asm = format!("jl {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jl {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
fn emit_jle(&mut self, dest_name: MuName) {
trace!("emit: jle {}", dest_name);
let asm = format!("jle {}", self.asm_block_label(dest_name.clone()));
let asm = format!("jle {}", symbol(self.mangle_block_label(dest_name.clone())));
self.add_asm_branch2(asm, dest_name);
}
......@@ -1919,9 +1918,15 @@ pub fn emit_context(vm: &VM) {
debug!("---finish---");
}
//#[cfg(target_os = "macos")]
fn directive_globl(name: String) -> String {
format!(".globl {}", name)
}
//
//#[cfg(target_os = "linux")]
//fn directive_globl(name: String) -> String {
// format!("global {}", name)
//}
fn directive_comm(name: String, size: ByteSize, align: ByteSize) -> String {
format!(".comm {},{},{}", name, size, align)
......
......@@ -13,4 +13,4 @@ pub extern crate ast;
pub extern crate utils;
pub mod vm;
pub mod compiler;
pub mod runtime;
pub mod runtime;
\ No newline at end of file
......@@ -13,12 +13,12 @@
__thread void* mu_tls;
void set_thread_local(void* thread) {
printf("Thread%p: setting mu_tls to %p\n", pthread_self(), thread);
printf("Thread%p: setting mu_tls to %p\n", (void*) pthread_self(), thread);
mu_tls = thread;
}
void* muentry_get_thread_local() {
printf("Thread%p: getting mu_tls as %p\n", pthread_self(), mu_tls);
printf("Thread%p: getting mu_tls as %p\n", (void*) pthread_self(), mu_tls);
return mu_tls;
}
......
......@@ -156,9 +156,7 @@ impl MuStack {
debug!("store {} to {}", val, stack_ptr);
unsafe {stack_ptr.store(val);}
}
// should have put 6 + 6 words on the stack
debug_assert!(self.sp.diff(stack_ptr) == 12 * WORD_SIZE);
// save it back
self.sp = stack_ptr;
......
......@@ -38,8 +38,15 @@ mod aot {
use std::path::PathBuf;
use std::process::Command;
use std::process::Output;
const CC : &'static str = "clang";
fn get_test_clang_path() -> String {
use std::env;
match env::var("CLANG_FOR_AOT") {
Ok(val) => val,
Err(_) => "clang".to_string()
}
}
fn exec (mut cmd: Command) -> Output {
println!("executing: {:?}", cmd);
......@@ -54,7 +61,7 @@ mod aot {
}
fn link_executable_internal (files: Vec<PathBuf>, out: PathBuf) -> PathBuf {
let mut gcc = Command::new(CC);
let mut gcc = Command::new(get_test_clang_path());
for file in files {
println!("link with {:?}", file.as_path());
......@@ -62,6 +69,13 @@ mod aot {
}
println!("output as {:?}", out.as_path());
if cfg!(target_os = "linux") {
gcc.arg("-lrt");
gcc.arg("-ldl");
gcc.arg("-lpthread");
}
// so we can find symbols in itself
gcc.arg("-rdynamic");
gcc.arg("-o");
gcc.arg(out.as_os_str());
......@@ -74,7 +88,7 @@ mod aot {
let mut object_files : Vec<PathBuf> = vec![];
for file in files {
let mut gcc = Command::new(CC);
let mut gcc = Command::new(get_test_clang_path());
gcc.arg("-c");
gcc.arg("-fpic");
......@@ -90,7 +104,7 @@ mod aot {
exec(gcc);
}
let mut gcc = Command::new(CC);
let mut gcc = Command::new(get_test_clang_path());
gcc.arg("-shared");
gcc.arg("-Wl");
gcc.arg("-undefined");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment