Skip to content

Commit

Permalink
Merge pull request rcore-os#215 from chyyuu/master
Browse files Browse the repository at this point in the history
Add libos-mode core-test  CI
  • Loading branch information
chyyuu authored Aug 28, 2021
2 parents ebd09da + 139c5aa commit 45f82c1
Show file tree
Hide file tree
Showing 15 changed files with 1,693 additions and 16 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/rustc20210727.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ jobs:
pip3 install pexpect
python3 core-tests.py
core-test-libos:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Pull prebuilt images
run: git lfs pull -I prebuilt/zircon/x64/core-tests.zbi,prebuilt/zircon/x64/libzircon-libos.so,prebuilt/zircon/x64/userboot-libos.so
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-07-27
components: rust-src
- name: Run core-tests
run: |
cd scripts
pip3 install pexpect
python3 unix-core-tests.py
libc-test:
runs-on: ubuntu-20.04
steps:
Expand Down Expand Up @@ -220,7 +239,9 @@ jobs:
- name: Pull prebuilt images
run: git lfs pull -I prebuilt/linux/libc-libos.so
- name: Install musl toolchain qemu-system-x86
run: sudo apt-get install musl-tools musl-dev qemu-system-x86 -y
run: |
sudo apt-get update
sudo apt-get install musl-tools musl-dev qemu-system-x86 -y
- name: Prepare rootfs and libc-test
run: make baremetal-test-img
- name: Build kernel
Expand All @@ -244,6 +265,7 @@ jobs:
components: rust-src
- name: Install cargo tools and qemu-system-riscv64
run: |
sudo apt update
sudo apt install qemu-utils
cargo install cargo-binutils
rustup component add llvm-tools-preview
Expand Down
26 changes: 24 additions & 2 deletions .github/workflows/rustcnightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
sudo apt update
sudo apt install qemu-system-x86
- run: echo "nightly" >rust-toolchain
- run: echo "nightly" >./rboot/rust-toolchain
- run: echo "nightly" >./rboot/rust-toolchain
- name: Build zCore
run: |
cd zCore
Expand All @@ -173,6 +173,25 @@ jobs:
pip3 install pexpect
python3 core-tests.py
core-test-libos:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Pull prebuilt images
run: git lfs pull -I prebuilt/zircon/x64/core-tests.zbi,prebuilt/zircon/x64/libzircon-libos.so,prebuilt/zircon/x64/userboot-libos.so
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rust-src
- name: Run core-tests
run: |
cd scripts
pip3 install pexpect
python3 unix-core-tests.py
libc-test:
runs-on: ubuntu-20.04
steps:
Expand Down Expand Up @@ -232,7 +251,9 @@ jobs:
- name: Pull prebuilt images
run: git lfs pull -I prebuilt/linux/libc-libos.so
- name: Install musl toolchain qemu-system-x86
run: sudo apt-get install musl-tools musl-dev qemu-system-x86 -y
run: |
sudo apt-get update
sudo apt-get install musl-tools musl-dev qemu-system-x86 -y
- name: Prepare rootfs and libc-test
run: make baremetal-test-img
- name: Build kernel
Expand All @@ -258,6 +279,7 @@ jobs:
- run: echo "nightly" >./rboot/rust-toolchain
- name: Install cargo tools and qemu-system-riscv64
run: |
sudo apt-get update
sudo apt install qemu-utils
cargo install cargo-binutils
rustup component add llvm-tools-preview
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,4 @@ baremetal-test:
@make -C zCore baremetal-test mode=release linux=1 | tee stdout-baremetal-test

baremetal-test-rv64:
@make -C zCore baremetal-test-rv64 arch=riscv64 mode=release linux=1 ROOTPROC=$(ROOTPROC) | tee -a stdout-baremetal-test-rv64 | tee stdout-rv64

@make -C zCore baremetal-test-rv64 arch=riscv64 mode=release linux=1 ROOTPROC=$(ROOTPROC) | tee -a stdout-baremetal-test-rv64 | tee stdout-rv64
77 changes: 77 additions & 0 deletions scripts/baremetal-core-tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import pexpect
import sys
import re
import os

TIMEOUT = 20
ZCORE_PATH = '../zCore'
BASE = 'zircon/'
OUTPUT_FILE = BASE + 'test-output-baremetal.txt'
RESULT_FILE = BASE + 'test-result-baremetal.txt'
CHECK_FILE = BASE + 'test-check-passed.txt'
DBG_FILE = BASE + 'dbg-b.txt'
TEST_CASE_FILE = BASE + 'testcases-all.txt'


class Tee:
def __init__(self, name, mode):
self.file = open(name, mode)
self.stdout = sys.stdout
sys.stdout = self

def __del__(self):
sys.stdout = self.stdout
self.file.close()

def write(self, data):
self.file.write(data)
self.stdout.write(data)

def flush(self):
self.file.flush()

if os.path.exists(OUTPUT_FILE): os.remove(OUTPUT_FILE)
if os.path.exists(RESULT_FILE): os.remove(RESULT_FILE)
if os.path.exists(DBG_FILE): os.remove(DBG_FILE)

with open(TEST_CASE_FILE, "r") as tcf:
lines = tcf.readlines()
for line in lines:
with open(DBG_FILE, "a") as dbg: print(line, file=dbg)

child = pexpect.spawn("make -C %s test mode=release test_filter='%s'" % (ZCORE_PATH, line.replace('\n','')),
timeout=TIMEOUT, encoding='utf-8')
child.logfile = Tee(OUTPUT_FILE, 'a')

index = child.expect(['finished!', 'panicked', pexpect.EOF, pexpect.TIMEOUT])
result = ['FINISHED', 'PANICKED', 'EOF', 'TIMEOUT'][index]
print(result)

passed = []
failed = []
passed_case = set()

# see https://stackoverflow.com/questions/59379174/ignore-ansi-colors-in-pexpect-response
ansi_escape = re.compile(r"\x1B[@-_][0-?]*[ -/]*[@-~]")

with open(OUTPUT_FILE, "r") as opf:
for line in opf:
line=ansi_escape.sub('',line)
with open(RESULT_FILE, "a") as rstf:
if line.startswith('[ OK ]'):
print(line, file=rstf)
elif line.startswith('[ FAILED ]') and line.endswith(')\n'):
print(line, file=rstf)


# with open(CHECK_FILE, 'r') as f:
# check_case = set([case.strip() for case in f.readlines()])

# not_passed = check_case - passed_case
# if not_passed:
# print('=== Failed cases ===')
# for case in not_passed:
# print(case)
# exit(1)
# else:
# print('All checked case passed!')
23 changes: 23 additions & 0 deletions scripts/unix-core-testone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pexpect
import sys
import re
import argparse

TIMEOUT = 300
ZIRCON_LOADER_PATH = 'zircon-loader'
PREBUILT_PATH = '../prebuilt/zircon/x64'
CMDLINE_BASE = 'LOG=warn:userboot=test/core-standalone-test:userboot.shutdown:core-tests='

parser = argparse.ArgumentParser()
parser.add_argument('testcase', nargs=1)
args = parser.parse_args()

child = pexpect.spawn("cargo run -p '%s' -- '%s' '%s' --debug " %
(ZIRCON_LOADER_PATH, PREBUILT_PATH, CMDLINE_BASE+args.testcase[0]),
timeout=TIMEOUT, encoding='utf-8')

child.logfile = sys.stdout

index = child.expect(['finished!', 'panicked', pexpect.EOF, pexpect.TIMEOUT])
result = ['FINISHED', 'PANICKED', 'EOF', 'TIMEOUT'][index]
print(result)
83 changes: 83 additions & 0 deletions scripts/unix-core-tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import pexpect
import sys
import re
import os

TIMEOUT = 300
ZIRCON_LOADER_PATH = 'zircon-loader'
BASE = 'zircon/'
OUTPUT_FILE = BASE + 'test-output-libos.txt'
RESULT_FILE = BASE + 'test-result-libos.txt'
CHECK_FILE = BASE + 'test-check-passed.txt'
TEST_CASE_ALL = BASE + 'testcases-all.txt'
TEST_CASE_EXCEPTION = BASE + 'testcases-failed-libos.txt'
PREBUILT_PATH = '../prebuilt/zircon/x64'
CMDLINE_BASE = 'LOG=warn:userboot=test/core-standalone-test:userboot.shutdown:core-tests='

class Tee:
def __init__(self, name, mode):
self.file = open(name, mode)
self.stdout = sys.stdout
sys.stdout = self

def __del__(self):
sys.stdout = self.stdout
self.file.close()

def write(self, data):
self.file.write(data)
self.stdout.write(data)

def flush(self):
self.file.flush()

if os.path.exists(OUTPUT_FILE): os.remove(OUTPUT_FILE)
if os.path.exists(RESULT_FILE): os.remove(RESULT_FILE)

with open(TEST_CASE_ALL, "r") as tcf:
all_case = set([case.strip() for case in tcf.readlines()])
with open(TEST_CASE_EXCEPTION, "r") as tcf:
exception_case = set([case.strip() for case in tcf.readlines()])
check_case = all_case - exception_case

for line in check_case:
child = pexpect.spawn("cargo run -p '%s' -- '%s' '%s' --debug" %
(ZIRCON_LOADER_PATH, PREBUILT_PATH, CMDLINE_BASE+line),
timeout=TIMEOUT, encoding='utf-8')

child.logfile = Tee(OUTPUT_FILE, 'a')

index = child.expect(['finished!', 'panicked', pexpect.EOF, pexpect.TIMEOUT])
result = ['FINISHED', 'PANICKED', 'EOF', 'TIMEOUT'][index]
# print(result)

passed = []
failed = []
passed_case = set()

# see https://stackoverflow.com/questions/59379174/ignore-ansi-colors-in-pexpect-response
ansi_escape = re.compile(r"\x1B[@-_][0-?]*[ -/]*[@-~]")


with open(OUTPUT_FILE, "r") as opf:
for line in opf.readlines():
line=ansi_escape.sub('',line)
if line.startswith('[ OK ]'):
passed += line
passed_case.add(line[13:].split(' ')[0])
elif line.startswith('[ FAILED ]') and line.endswith(')\n'):
failed += line

with open(RESULT_FILE, "a") as rstf:
rstf.writelines(passed)
rstf.writelines(failed)


not_passed = check_case - passed_case
if not_passed:
print('=== Failed cases ===')
for case in not_passed:
print(case)
exit(1)
else:
print('All checked case passed!')
6 changes: 6 additions & 0 deletions scripts/zircon/test-output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
 Finished dev [unoptimized + debuginfo] target(s) in 0.04s
 Running `/home/deathwish/Append/code/ZCORE/zCore/target/debug/zircon-loader ../prebuilt/zircon/x64 'LOG=warn:userboot=test/core-standalone-test:userboot.shutdown:core-tests=*,-Bti.NoDelayedUnpin,Bti.DecommitRace,ProcessDebugVDSO.*,HandleCloseTest.ManyDuplicateTest*,JobTest.*,JobGetInfoTest.InfoJobProcessesPartiallyUnmappedBufferIsInvalidArgs,JobGetInfoTest.InfoJobChildrenPartiallyUnmappedBufferIsInvalidArgs,PortTest.AsyncWaitInvalidOption,PortTest.Timestamp,PortStressTest.WaitSignalCancel,PortStressTest.SignalCloseWait,ProcessTest.ProcessWaitAsyncCancelSelf,Pthread.*,PThreadBarrierTest.SingleThreadWinsBarrierObjectResetsBetweenIterations,SyncMutex.NoRecursion,Threads.Reading*State,Threads.DebugRegistersValidation,Threads.NoncanonicalRipAddressIRETQ,Threads.StartSuspendedThread,Threads.X86AcFlagUserCopy,Vmar.ProtectOverDemandPagedTest,Vmar.ProtectLargeUncomittedTest,Vmar.UnmapLargeUncommittedTest,Vmar.NestedRegionPermsTest,Vmar.MapSpecificOverwriteTest,Vmar.MapOverDestroyedTest,MemoryMappingTest.MprotectTest,MemoryMappingTest.MmapProtExecTest,MemoryMappingTest.MmapProtTest,VmoTestCase.ReadOnlyMap,VmoTestCase.MapRead,VmoTestCase.ParallelRead,VmoTestCase.NoPermMap,VmoTestCase.NoPermProtect,VmoTestCase.Commit,VmoTestCase.CacheOp,VmoTestCase.ResizeHazard,VmoTestCase.Cache*,VmoTestCase.ZeroPage,VmoTestCase.PinTests,VmoCloneTestCase.Commit,VmoClone2TestCase.PinClonePages,SocketTest.ReadIntoBadBuffer,SocketTest.WriteFromBadBuffer,VersionTest.*,BadAccessTest.*,InterruptTest.BindTriggeredIrqToPort,InterruptTest.WaitThreadFunctionsAfterSuspendResume,*Profile*,SystemEvent.*,Resource.*' --debug`
userboot: option "LOG=warn"
userboot: option "userboot=test/core-standalone-test"
userboot: option "userboot.shutdown"
userboot: option "core-tests=*,-Bti.NoDelayedUnpin,Bti.DecommitRace,ProcessDebugVDSO.*,HandleCloseTest.ManyDuplicateTest*,JobTest.*,JobGetInfoTest.InfoJobProcessesPartiallyUnmappedBufferIsInvalidArgs,JobGetInfoTest.InfoJobCh
Empty file added scripts/zircon/test-result.txt
Empty file.
Loading

0 comments on commit 45f82c1

Please sign in to comment.