diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml deleted file mode 100644 index 0aac51726..000000000 --- a/.github/workflows/makefile.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Test Makefile -on: - pull_request: - -env: - PYTHONUNBUFFERED: "1" - -jobs: - test-makefile: - name: Test Makefile - runs-on: ubuntu-24.04 - steps: - - name: Check out repository code - uses: actions/checkout@v2 - with: - path: tests - depth: 1 - - - name: Check out openwrt.git - uses: actions/checkout@v2 - with: - repository: openwrt/openwrt - path: openwrt - depth: 1 - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get -y install \ - python3-poetry \ - qemu-system-mips \ - qemu-system-x86 \ - qemu-system-aarch64 \ - make \ - bats - - - name: Link tests to openwrt.git - run: | - ln -s $GITHUB_WORKSPACE/tests $GITHUB_WORKSPACE/openwrt/tests - - - name: Workaround to add tests Makefile - run: | - echo "include tests/Makefile" >> $GITHUB_WORKSPACE/openwrt/Makefile - - - name: Check and install dependencies - run: | - cd $GITHUB_WORKSPACE/openwrt - make tests/setup V=s - - - name: Download OpenWrt firmware for testing - run: | - cd $GITHUB_WORKSPACE/openwrt - mkdir -p bin/targets/x86/64 - wget https://downloads.openwrt.org/releases/23.05.3/targets/x86/64/openwrt-23.05.3-x86-64-generic-squashfs-combined.img.gz \ - --output-document bin/targets/x86/64/openwrt-x86-64-generic-squashfs-combined.img.gz - - - name: Run QEMU test - run: | - cd $GITHUB_WORKSPACE/openwrt - make tests/x86-64 V=s - - - name: Run shell test - run: | - cd $GITHUB_WORKSPACE/openwrt - make tests/shell V=s diff --git a/.github/workflows/qemu.yml b/.github/workflows/qemu.yml index f7240edcf..8d71cc728 100644 --- a/.github/workflows/qemu.yml +++ b/.github/workflows/qemu.yml @@ -22,6 +22,18 @@ jobs: firmware: openwrt-malta-be-vmlinux-initramfs.elf dependency: qemu-system-mips + - target: malta-le + firmware: openwrt-malta-le-vmlinux-initramfs.elf + dependency: qemu-system-mipsel + + - target: malta-be64 + firmware: openwrt-malta-be64-vmlinux-initramfs.elf + dependency: qemu-system-mips64 + + - target: malta-le64 + firmware: openwrt-malta-le64-vmlinux-initramfs.elf + dependency: qemu-system-mips64el + - target: x86-64 firmware: openwrt-x86-64-generic-squashfs-combined.img.gz dependency: qemu-system-x86 @@ -33,6 +45,16 @@ jobs: steps: - name: Check out repository code uses: actions/checkout@v2 + with: + path: tests + depth: 1 + + - name: Check out openwrt.git + uses: actions/checkout@v2 + with: + repository: openwrt/openwrt + path: openwrt + depth: 1 - name: Install dependencies run: | @@ -41,8 +63,13 @@ jobs: python3-poetry \ ${{ matrix.dependency }} - - name: Install project dependencies + - name: Link tests to openwrt.git + run: | + ln -s $GITHUB_WORKSPACE/tests $GITHUB_WORKSPACE/openwrt/tests + + - name: Poetry install run: | + cd $GITHUB_WORKSPACE/tests poetry install - name: Download test firmware @@ -50,20 +77,18 @@ jobs: target: ${{ matrix.target }} run: | wget https://downloads.openwrt.org/snapshots/targets/${target/-/\/}/${{ matrix.firmware }} \ - --output-document ${{ matrix.firmware }} + --output-document $GITHUB_WORKSPACE/openwrt/${{ matrix.firmware }} - name: Run test run: | + cd $GITHUB_WORKSPACE/openwrt + gunzip ${{ matrix.firmware }} || true firmware=${{ matrix.firmware }} - poetry run pytest tests/ \ - --lg-env targets/qemu-${{ matrix.target }}.yaml \ - --lg-log \ - --lg-colored-steps \ - -v \ - -s \ - --firmware $GITHUB_WORKSPACE/${firmware/.gz/} + + make tests/${{ matrix.target }} \ + FIRMWARE=$GITHUB_WORKSPACE/${firmware/.gz/} - name: Upload console logs uses: actions/upload-artifact@v2 diff --git a/.github/workflows/shell.yml b/.github/workflows/shell.yml new file mode 100644 index 000000000..be7e6e687 --- /dev/null +++ b/.github/workflows/shell.yml @@ -0,0 +1,40 @@ +name: Test Shell +on: + pull_request: + +env: + PYTHONUNBUFFERED: "1" + +jobs: + test-makefile: + name: Test Makefile + runs-on: ubuntu-24.04 + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + path: tests + depth: 1 + + - name: Check out openwrt.git + uses: actions/checkout@v2 + with: + repository: openwrt/openwrt + path: openwrt + depth: 1 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get -y install \ + make \ + bats + + - name: Link tests to openwrt.git + run: | + ln -s $GITHUB_WORKSPACE/tests $GITHUB_WORKSPACE/openwrt/tests + + - name: Run shell test + run: | + cd $GITHUB_WORKSPACE/openwrt + make tests/shell V=s diff --git a/Makefile b/Makefile index ee742cc22..8fe869fd2 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ TESTSDIR ?= $(shell readlink -f $(TOPDIR)/tests) define pytest poetry -C $(TESTSDIR) run \ pytest $(TESTSDIR)/tests/ \ + --verbose \ --lg-log \ --lg-colored-steps $(if $(K),-k $(K),) endef @@ -59,15 +60,35 @@ $(curdir)/armsr-armv8: --lg-env $(TESTSDIR)/targets/qemu-armsr-armv8.yaml \ --firmware $(FIRMWARE) -$(curdir)/malta-be: QEMU_BIN ?= qemu-system-mips -$(curdir)/malta-be: FIRMWARE ?= $(TOPDIR)/bin/targets/malta/be/openwrt-malta-be-vmlinux-initramfs.elf -$(curdir)/malta-be: +define qemu_malta [ -f $(FIRMWARE) ] LG_QEMU_BIN=$(QEMU_BIN) \ $(pytest) \ - --lg-env $(TESTSDIR)/targets/qemu-malta-be.yaml \ + --lg-env $(TESTSDIR)/targets/qemu-malta.yaml \ --firmware $(FIRMWARE) +endef + + +$(curdir)/malta-be: QEMU_BIN ?= qemu-system-mips +$(curdir)/malta-be: FIRMWARE ?= $(TOPDIR)/bin/targets/malta/be/openwrt-malta-be-vmlinux-initramfs.elf +$(curdir)/malta-be: + $(qemu_malta) + +$(curdir)/malta-le: QEMU_BIN ?= qemu-system-mipsel +$(curdir)/malta-le: FIRMWARE ?= $(TOPDIR)/bin/targets/malta/le/openwrt-malta-le-vmlinux-initramfs.elf +$(curdir)/malta-le: + $(qemu_malta) + +$(curdir)/malta-be64: QEMU_BIN ?= qemu-system-mips64 +$(curdir)/malta-be64: FIRMWARE ?= $(TOPDIR)/bin/targets/malta/be64/openwrt-malta-be64-vmlinux-initramfs.elf +$(curdir)/malta-be64: + $(qemu_malta) + +$(curdir)/malta-le64: QEMU_BIN ?= qemu-system-mips64el +$(curdir)/malta-le64: FIRMWARE ?= $(TOPDIR)/bin/targets/malta/le64/openwrt-malta-le64-vmlinux-initramfs.elf +$(curdir)/malta-le64: + $(qemu_malta) $(curdir)/shell: [ -n "$$(command -v bats)" ] || (echo "Please install bats" && exit 1) diff --git a/targets/qemu-malta-be.yaml b/targets/qemu-malta.yaml similarity index 99% rename from targets/qemu-malta-be.yaml rename to targets/qemu-malta.yaml index 57cc0d6ec..bc736a865 100644 --- a/targets/qemu-malta-be.yaml +++ b/targets/qemu-malta.yaml @@ -2,6 +2,7 @@ features: - online - opkg - hwsim + - apk targets: main: