From f604c7ff49c6fc0aab8ce60512ec6ffeb54c678d Mon Sep 17 00:00:00 2001 From: Niall Mullane Date: Wed, 14 Jul 2021 10:10:55 -0400 Subject: [PATCH] Fix #289, Add RTEMS build and test workflows Add two workflows for building and testing cFS in both RTEMS 4.11 and 5 Add scripts folder into .github for running all unit tests inside QEMU Use dockerhub to store docker image containing all QEMU and RTEMS toolchain and dependencies Address PR comments by jphickey: Remove monitoring of stdout by correctly using batch-mode option Correctly use make SIMULATION variable instead of manually modifying targets.cmake during the actions workflow. Address PR comments by zanzaben: Remove forgotten targets.cmake target system Use makefile to run qemu tests and create qemu disk images instead of shell scripts --- .github/scripts/common-test.mk | 143 ++++++++++++++++++++++ .github/scripts/rtems-test.mk | 63 ++++++++++ .github/workflows/build-cfs-rtems4.11.yml | 124 +++++++++++++++++++ .github/workflows/build-cfs-rtems5.yml | 124 +++++++++++++++++++ 4 files changed, 454 insertions(+) create mode 100644 .github/scripts/common-test.mk create mode 100644 .github/scripts/rtems-test.mk create mode 100644 .github/workflows/build-cfs-rtems4.11.yml create mode 100644 .github/workflows/build-cfs-rtems5.yml diff --git a/.github/scripts/common-test.mk b/.github/scripts/common-test.mk new file mode 100644 index 000000000..6b322524e --- /dev/null +++ b/.github/scripts/common-test.mk @@ -0,0 +1,143 @@ +CPUNAME ?= cpu1 +INSTALL_DIR ?= $(O)/exe + +ALL_OSAL_FUNC_TESTS := \ + bin-sem-flush-test \ + bin-sem-test \ + bin-sem-timeout-test \ + count-sem-test \ + file-api-test \ + file-sys-add-fixed-map-api-test \ + idmap-api-test \ + mutex-test \ + osal-core-test \ + queue-test \ + sem-speed-test \ + symbol-api-test \ + time-base-api-test \ + timer-add-api-test \ + timer-test + +# These functional tests require a network stack, +# so they can be skipped on platforms that may not have network +ifeq ($(SKIP_NET_TESTS),) +ALL_OSAL_FUNC_TESTS += \ + network-api-test \ + select-test +endif + + +ALL_OSAL_PARAM_TESTS := \ + osal_core_UT \ + osal_filesys_UT \ + osal_file_UT \ + osal_loader_UT \ + osal_network_UT \ + osal_timer_UT \ + +ALL_CFE_COVERAGE_TESTS := \ + coverage-es-ALL-testrunner \ + coverage-evs-ALL-testrunner \ + coverage-fs-ALL-testrunner \ + coverage-sb-ALL-testrunner \ + coverage-tbl-ALL-testrunner \ + coverage-time-ALL-testrunner \ + msg_UT resourceid_UT \ + sbr_map_direct_UT sbr_map_hash_UT + +ALL_OSAL_COVERAGE_TESTS := \ + coverage-shared-binsem-testrunner \ + coverage-shared-clock-testrunner \ + coverage-shared-common-testrunner \ + coverage-shared-countsem-testrunner \ + coverage-shared-dir-testrunner \ + coverage-shared-errors-testrunner \ + coverage-shared-filesys-testrunner \ + coverage-shared-file-testrunner \ + coverage-shared-heap-testrunner \ + coverage-shared-idmap-testrunner \ + coverage-shared-module-testrunner \ + coverage-shared-mutex-testrunner \ + coverage-shared-network-testrunner \ + coverage-shared-printf-testrunner \ + coverage-shared-queue-testrunner \ + coverage-shared-select-testrunner \ + coverage-shared-sockets-testrunner \ + coverage-shared-task-testrunner \ + coverage-shared-timebase-testrunner \ + coverage-shared-time-testrunner \ + coverage-vxworks-binsem-testrunner \ + coverage-vxworks-bsd-select-testrunner \ + coverage-vxworks-bsd-sockets-testrunner \ + coverage-vxworks-common-testrunner \ + coverage-vxworks-console-bsp-testrunner \ + coverage-vxworks-console-testrunner \ + coverage-vxworks-countsem-testrunner \ + coverage-vxworks-dirs-globals-testrunner \ + coverage-vxworks-files-testrunner \ + coverage-vxworks-filesys-testrunner \ + coverage-vxworks-heap-testrunner \ + coverage-vxworks-idmap-testrunner \ + coverage-vxworks-loader-testrunner \ + coverage-vxworks-mutex-testrunner \ + coverage-vxworks-network-testrunner \ + coverage-vxworks-no-loader-testrunner \ + coverage-vxworks-no-shell-testrunner \ + coverage-vxworks-posix-files-testrunner \ + coverage-vxworks-posix-dirs-testrunner \ + coverage-vxworks-posix-gettime-testrunner \ + coverage-vxworks-posix-io-testrunner \ + coverage-vxworks-queues-testrunner \ + coverage-vxworks-shell-testrunner \ + coverage-vxworks-symtab-testrunner \ + coverage-vxworks-tasks-testrunner \ + coverage-vxworks-timebase-testrunner \ + coverage-ut-mcp750-vxworks-testrunner + +ALL_CFE_TEST_LIST := $(addprefix $(INSTALL_DIR)/$(CPUNAME)/, \ + $(ALL_CFE_COVERAGE_TESTS) \ +) + +ALL_OS_TEST_COV_LIST := $(addprefix $(INSTALL_DIR)/$(CPUNAME)/, \ + $(ALL_OSAL_COVERAGE_TESTS) \ +) + +ALL_OS_TEST_PARAM_LIST := $(addprefix $(INSTALL_DIR)/$(CPUNAME)/, \ + $(ALL_OSAL_PARAM_TESTS) \ +) + +ALL_OS_TEST_FUNC_LIST := $(addprefix $(INSTALL_DIR)/$(CPUNAME)/, \ + $(ALL_OSAL_FUNC_TESTS) \ +) + + +ALL_TEST_LIST := \ + $(ALL_CFE_TEST_LIST) \ + $(ALL_OS_TEST_COV_LIST) \ + $(ALL_OS_TEST_PARAM_LIST) \ + $(ALL_OS_TEST_FUNC_LIST) \ + +.PHONY: clean_logs \ + all_tests \ + all_logs \ + all_checks \ + all_cfe_cov_logs \ + all_osal_cov_logs \ + all_osal_param_logs \ + all_osal_func_logs + +clean_logs: + rm -f $(addsuffix .check,$(ALL_TEST_LIST)) \ + $(addsuffix .log,$(ALL_TEST_LIST)) + +all_logs: $(addsuffix .log,$(ALL_TEST_LIST)) +all_checks: $(addsuffix .check,$(ALL_TEST_LIST)) + +all_cfe_cov_logs: $(addsuffix .log,$(ALL_CFE_TEST_LIST)) +all_osal_cov_logs: $(addsuffix .log,$(ALL_OS_TEST_COV_LIST)) +all_osal_param_logs: $(addsuffix .log,$(ALL_OS_TEST_PARAM_LIST)) +all_osal_func_logs: $(addsuffix .log,$(ALL_OS_TEST_FUNC_LIST)) + +all_tests: all_checks + @echo '*** SUCCESS ***' + diff --git a/.github/scripts/rtems-test.mk b/.github/scripts/rtems-test.mk new file mode 100644 index 000000000..11bf5af65 --- /dev/null +++ b/.github/scripts/rtems-test.mk @@ -0,0 +1,63 @@ +SKIP_NET_TESTS := 1 + +# At a minimum the variable O must be set by the caller +ifeq ($(O),) +$(error O must be set prior to native-test.mk) +endif + +CFE_IMG_MB ?= 32 +CFE_DISK_IMG ?= $(INSTALL_DIR)/$(CPUNAME)/nonvol-disk.img +CFE_FS_IMG ?= $(INSTALL_DIR)/$(CPUNAME)/nonvol-fs.img +QEMU_COMMAND ?= qemu-system-i386 -m 128 +MACADDR = 00:04:9F$(shell head -c 3 /dev/urandom | hexdump -v -e '/1 ":%02X"') +RTEMS_VERSION ?= i686-rtems5 + +# default rule to just create qemu disk image +all: cfe-disk + +# include list of all unit tests to run +include .github/scripts/common-test.mk + +.PHONY: run cfe-disk +.SECONDARY: $(addsuffix .log,$(ALL_TEST_LIST))) + +cfe-disk: $(CFE_DISK_IMG) + +$(CFE_DISK_IMG): FS_SIZE := $(shell echo $$(($(CFE_IMG_MB) * 1048576))) + +$(CFE_DISK_IMG): $(wildcard $(O)/$(RTEMS_VERSION)/default_cpu1/osal/unit-tests/osloader-test/utmod/*) $(wildcard $(INSTALL_DIR)/$(CPUNAME)/eeprom/*) + # Basic disk + truncate -s $(FS_SIZE) $(@) + parted -s $(@) -- mklabel msdos + parted -a none -s $(@) -- mkpart primary fat32 63s -1s + # File system partition + mkfs.fat --offset 63 $(@) + mcopy -i $(@)@@32256 -sv $(O)/$(RTEMS_VERSION)/default_cpu1/osal/unit-tests/osloader-test/utmod :: || /bin/true + mcopy -i $(@)@@32256 -sv $(INSTALL_DIR)/$(CPUNAME)/eeprom :: + +run: $(CFE_DISK_IMG) + $(QEMU_COMMAND) -display none -no-reboot -serial mon:stdio \ + -kernel $(INSTALL_DIR)/$(CPUNAME)/$(KERNEL_NAME).exe \ + -drive file=$(CFE_DISK_IMG),format=raw \ + -device i82557b,netdev=net0,mac=$(MACADDR) \ + -netdev user,id=net0,hostfwd=udp:127.0.0.1:1235-:1235 \ + -append '--console=/dev/com1' + +clean_img: + rm -f $(INSTALL_DIR)/$(CPUNAME)/*.img + +%.cow: $(CFE_DISK_IMG) + qemu-img create -o backing_file=$(notdir $(CFE_DISK_IMG)),backing_fmt=raw -f qcow2 $(@) + +%.log: %.exe %.cow + $(QEMU_COMMAND) -no-reboot -display none \ + -kernel $(<) \ + -append '--batch-mode --console=/dev/com1' \ + -drive file=$(*).cow,format=qcow2 \ + -device i82557b,netdev=net0,mac=$(MACADDR) \ + -netdev user,id=net0 \ + -serial file:$(@).tmp + @mv -v $(@).tmp $(@) + +%.check: %.log + @(grep -q '^Application exit status: SUCCESS' $(<)) || (echo $(*): ---FAIL---; /bin/false ) diff --git a/.github/workflows/build-cfs-rtems4.11.yml b/.github/workflows/build-cfs-rtems4.11.yml new file mode 100644 index 000000000..e76ea9d61 --- /dev/null +++ b/.github/workflows/build-cfs-rtems4.11.yml @@ -0,0 +1,124 @@ +name: Build and Test rtems 4.11 [OMIT_DEPRECATED=true] + +# Run every time a new commit pushed or for pull requests +on: + push: + pull_request: + +env: + OMIT_DEPRECATED: true + +jobs: + #Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action. + check-for-duplicates: + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + concurrent_skipping: 'same_content' + skip_after_successful_duplicate: 'true' + do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' + + build-cfs: + #Continue if check-for-duplicates found no duplicates. Always runs for pull-requests. + needs: check-for-duplicates + if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }} + name: Build + runs-on: ubuntu-18.04 + container: nmullane/qemu_rtems:4.11 + + strategy: + fail-fast: false + matrix: + buildtype: [debug, release] + + # Set the type of machine to run on + env: + BUILDTYPE: ${{ matrix.buildtype }} + # Set home to where rtems is located + HOME: /root + + steps: + # Check out the cfs bundle + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: true + + # Setup the build system + - name: Copy Files + run: | + cp ./cfe/cmake/Makefile.sample Makefile + cp -r ./cfe/cmake/sample_defs sample_defs + + # Setup the build system + - name: Make Prep + run: make SIMULATION=i686-rtems4.11 prep + + - name: Make + run: make + + test-cfs: + name: Test + runs-on: ubuntu-18.04 + container: nmullane/qemu_rtems:4.11 + + needs: build-cfs + + strategy: + fail-fast: false + matrix: + buildtype: [debug, release] + + # Set the type of machine to run on + env: + BUILDTYPE: ${{ matrix.buildtype }} + ENABLE_UNIT_TESTS: true + # Set home to where rtems is located + HOME: /root + # Disable mcopy check otherwise disk image build fails + MTOOLS_SKIP_CHECK: 1 + + + steps: + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: true + + # Setup the build system + - name: Copy Files + run: | + cp ./cfe/cmake/Makefile.sample Makefile + cp -r ./cfe/cmake/sample_defs sample_defs + + # Setup the build system + - name: Make + run: | + make SIMULATION=i686-rtems4.11 prep + make install + + - name: Test + #run: .github/scripts/qemu_test.sh && .github/scripts/log_failed_tests.sh + run: make O=build RTEMS_VERSION=i686-rtems4.11 -f .github/scripts/rtems-test.mk all_tests + + # Archive test logs before checking for errors + - name: Archive cFS Test Artifacts + uses: actions/upload-artifact@v2 + with: + name: cFS-rtems-log-summary-${{ matrix.buildtype }} + path: ./build/exe/cpu1/*.log + + - name: Check for Errors + run: | + # Check if failed-tests is empty or not + if [ -s ./build/exe/cpu1/failed-tests.txt ]; then + echo "Failing tests found:" + cat ./build/exe/cpu1/failed-tests.txt + exit -1 + fi diff --git a/.github/workflows/build-cfs-rtems5.yml b/.github/workflows/build-cfs-rtems5.yml new file mode 100644 index 000000000..1f66a7d69 --- /dev/null +++ b/.github/workflows/build-cfs-rtems5.yml @@ -0,0 +1,124 @@ +name: Build and Test rtems 5 [OMIT_DEPRECATED=true] + +# Run every time a new commit pushed or for pull requests +on: + push: + pull_request: + +env: + OMIT_DEPRECATED: true + +jobs: + #Checks for duplicate actions. Skips push actions if there is a matching or duplicate pull-request action. + check-for-duplicates: + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + concurrent_skipping: 'same_content' + skip_after_successful_duplicate: 'true' + do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' + + build-cfs: + #Continue if check-for-duplicates found no duplicates. Always runs for pull-requests. + needs: check-for-duplicates + if: ${{ needs.check-for-duplicates.outputs.should_skip != 'true' }} + name: Build + runs-on: ubuntu-18.04 + container: nmullane/qemu_rtems:5 + + strategy: + fail-fast: false + matrix: + buildtype: [debug, release] + + # Set the type of machine to run on + env: + BUILDTYPE: ${{ matrix.buildtype }} + # Set home to where rtems is located + HOME: /root + + steps: + # Check out the cfs bundle + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: true + + # Setup the build system + - name: Copy Files + run: | + cp ./cfe/cmake/Makefile.sample Makefile + cp -r ./cfe/cmake/sample_defs sample_defs + + # Setup the build system + - name: Make Prep + run: make SIMULATION=i686-rtems5 prep + + - name: Make + run: make + + test-cfs: + name: Test + runs-on: ubuntu-18.04 + container: nmullane/qemu_rtems:5 + + needs: build-cfs + + strategy: + fail-fast: false + matrix: + buildtype: [debug, release] + + # Set the type of machine to run on + env: + BUILDTYPE: ${{ matrix.buildtype }} + ENABLE_UNIT_TESTS: true + # Set home to where rtems is located + HOME: /root + # Disable mcopy check otherwise disk image build fails + MTOOLS_SKIP_CHECK: 1 + + + steps: + # Checks out a copy of your repository on the ubuntu-latest machine + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: true + + # Setup the build system + - name: Copy Files + run: | + cp ./cfe/cmake/Makefile.sample Makefile + cp -r ./cfe/cmake/sample_defs sample_defs + + # Setup the build system + - name: Make + run: | + make SIMULATION=i686-rtems5 prep + make install + + - name: Test + #run: .github/scripts/qemu_test.sh && .github/scripts/log_failed_tests.sh + run: make O=build RTEMS_VERSION=i686-rtems5 -f .github/scripts/rtems-test.mk all_tests + + # Archive test logs before checking for errors + - name: Archive cFS Test Artifacts + uses: actions/upload-artifact@v2 + with: + name: cFS-rtems-log-summary-${{ matrix.buildtype }} + path: ./build/exe/cpu1/*.log + + - name: Check for Errors + run: | + # Check if failed-tests is empty or not + if [ -s ./build/exe/cpu1/failed-tests.txt ]; then + echo "Failing tests found:" + cat ./build/exe/cpu1/failed-tests.txt + exit -1 + fi