From db8e7eb0aaa5fc14ea2a9ed115eb5b6f21737d5a Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Wed, 24 Feb 2021 21:19:06 -0500 Subject: [PATCH] cross-canary: Add simple test to validate cross work At least, to a basic level. --- overlay/mobile-nixos/cross-canary/test.nix | 45 ++++++++++++++++++++++ overlay/overlay.nix | 2 + 2 files changed, 47 insertions(+) create mode 100644 overlay/mobile-nixos/cross-canary/test.nix diff --git a/overlay/mobile-nixos/cross-canary/test.nix b/overlay/mobile-nixos/cross-canary/test.nix new file mode 100644 index 00000000..7933cf29 --- /dev/null +++ b/overlay/mobile-nixos/cross-canary/test.nix @@ -0,0 +1,45 @@ +{ stdenv, runCommandNoCC, runtimeShell, busybox, hello-mruby, pkgsBuildBuild }: + +let + inherit (stdenv) system; + emulators = { + "aarch64-linux" = "qemu-aarch64"; + "armv7l-linux" = "qemu-arm"; + }; + emulator = + if stdenv.buildPlatform == stdenv.hostPlatform then "" + else "${pkgsBuildBuild.qemu}/bin/${emulators.${system}}" + ; + mkTest = what: script: runCommandNoCC "cross-canary-${what}-${stdenv.system}" {} '' + ( + PS4=" $ " + set -x + + ${script} + + ) + + # Everything went okay, mark the build as a success! + touch $out + ''; +in + +# We're not creating a "useless" canary when there is no cross compilation. +if stdenv.buildPlatform == stdenv.hostPlatform then {} else +{ + busybox = mkTest "busybox" '' + # Checks that busybox works + ${emulator} ${busybox}/bin/busybox uname -a + ${emulator} ${busybox}/bin/busybox sh -c 'echo busybox works...' + ''; + + mruby = mkTest "mruby" '' + # Checks that mruby works at its most basic. + ${emulator} ${hello-mruby}/bin/hello + ''; + + runtimeShell = mkTest "runtimeShell" '' + # And what about runtimeShell? + ${emulator} ${runtimeShell} -c 'echo runtimeShell works...' + ''; +} diff --git a/overlay/overlay.nix b/overlay/overlay.nix index 4da5a113..c1e5e632 100644 --- a/overlay/overlay.nix +++ b/overlay/overlay.nix @@ -136,6 +136,8 @@ in make-flashable-zip = callPackage ./mobile-nixos/android-flashable-zip/make-flashable-zip.nix {}; map-dtbs = callPackage ./mobile-nixos/map-dtbs {}; + + cross-canary-test = callPackage ./mobile-nixos/cross-canary/test.nix {}; }; imageBuilder = callPackage ../lib/image-builder {};