Add more test cases to increase code coverage rate

Signed-off-by: Zheng, Qi <huaiqing.zq@antgroup.com>
This commit is contained in:
Zheng, Qi 2021-09-30 16:58:36 +08:00 committed by Zongmin.Gu
parent d1e9ed12f1
commit 26b6299f3d

@ -1,10 +1,10 @@
name: Code Coverage
# Controls when the action will run. Triggers the workflow on push or pull request
on: [push, pull_request]
on: [push]
env:
nap_time: 60
nap_time: 120
jobs:
Collect-code-coverage:
@ -20,16 +20,6 @@ jobs:
- name: Create container
run: docker run -itd --name=code_coverage -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:${{ env.OCCLUM_VERSION }}-ubuntu18.04
- name: Change download source of crates.io
run: |
docker exec code_coverage bash -c "cat <<- EOF >/root/.cargo/config
[source.crates-io]
registry = \"https://github.com/rust-lang/crates.io-index\"
replace-with = 'ustc'
[source.ustc]
registry = \"git://mirrors.ustc.edu.cn/crates.io-index\"
EOF"
- name: Build dependencies
run: docker exec code_coverage bash -c "cargo uninstall sccache || true; cd /root/occlum; make submodule"
@ -42,6 +32,59 @@ jobs:
- name: Integration test with Glibc
run: docker exec code_coverage bash -c "cd /root/occlum; SGX_MODE=SIM make test-glibc"
- name: C test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/hello_c && make;
occlum new occlum_instance;
cd occlum_instance && rm -rf image;
copy_bom -f ../hello.yaml --root image --include-dir /opt/occlum/etc/template;
SGX_MODE=SIM occlum build;
occlum run /bin/hello_world"
- name: C with encrypted image test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/hello_c && make;
rm -rf occlum_instance && occlum new occlum_instance;
occlum gen-image-key occlum_instance/image_key;
cd occlum_instance && rm -rf image;
copy_bom -f ../hello.yaml --root image --include-dir /opt/occlum/etc/template;
SGX_MODE=SIM occlum build --image-key ./image_key --buildin-image-key;
occlum run /bin/hello_world"
- name: C++ test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/hello_cc && make;
occlum new occlum_instance;
cd occlum_instance && rm -rf image;
copy_bom -f ../hello.yaml --root image --include-dir /opt/occlum/etc/template;
SGX_MODE=SIM occlum build;
occlum run /bin/hello_world"
- name: Rust test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/rust && SGX_MODE=SIM ./run_rust_demo_on_occlum.sh"
- name: Run Golang sqlite test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/golang/go_sqlite/ && SGX_MODE=SIM ./run_go_sqlite_demo.sh"
- name: Build Fish dependencies
run: docker exec code_coverage bash -c "cd /root/occlum/demos/fish && ./download_and_build.sh"
- name: Run Fish test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/fish && SGX_MODE=SIM ./run_fish_test.sh"
- name: Run Fish process rlimit test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/fish && SGX_MODE=SIM ./run_per_process_config_test.sh"
- name: Build LA dependencies
run: docker exec code_coverage bash -c "cd /root/occlum/demos/local_attestation && ./download_src_and_build_deps.sh"
- name: Run LA test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/local_attestation && SGX_MODE=SIM make;
SGX_MODE=SIM make test"
- name: Build sqlite dependencies
run: docker exec code_coverage bash -c "cd /root/occlum/demos/sqlite && ./download_and_build_sqlite.sh"
- name: Run sqlite test
run: docker exec code_coverage bash -c "cd /root/occlum/demos/sqlite && SGX_MODE=SIM ./run_sqlite_on_occlum.sh"
- name: Upload coverage report
run: docker exec code_coverage bash -c "cd /root/occlum/build/internal/src/libos/cargo-target/debug/deps; export CODECOV_TOKEN="${{ secrets.COV_TOKEN }}"; bash <(curl -s https://codecov.io/bash)"