1# Not everyone has a suitable remote builder set up, so the cross-compilation
2# tests that _include_ running the result are separate. That way, most people
3# can run the majority of the test suite without the extra setup.
4
5
6import ./make-test-python.nix ({ pkgs, ... }:
7let
8
9 remoteSystem =
10 if pkgs.system == "aarch64-linux"
11 then "x86_64-linux"
12 else "aarch64-linux";
13
14 remoteCrossPkgs = import ../.. /*nixpkgs*/ {
15 # NOTE: This is the machine that runs the build - local from the
16 # 'perspective' of the build script.
17 localSystem = remoteSystem;
18
19 # NOTE: Since this file can't control where the test will be _run_ we don't
20 # cross-compile _to_ a different system but _from_ a different system
21 crossSystem = pkgs.system;
22 };
23
24 hello1 = remoteCrossPkgs.dockerTools.buildImage {
25 name = "hello1";
26 tag = "latest";
27 contents = remoteCrossPkgs.hello;
28 };
29
30 hello2 = remoteCrossPkgs.dockerTools.buildLayeredImage {
31 name = "hello2";
32 tag = "latest";
33 contents = remoteCrossPkgs.hello;
34 };
35
36in {
37 name = "docker-tools";
38 meta = with pkgs.lib.maintainers; {
39 maintainers = [ roberth ];
40 };
41
42 nodes = {
43 docker = { ... }: {
44 virtualisation = {
45 diskSize = 2048;
46 docker.enable = true;
47 };
48 };
49 };
50
51 testScript = ''
52 docker.wait_for_unit("sockets.target")
53
54 with subtest("Ensure cross compiled buildImage image can run."):
55 docker.succeed(
56 "docker load --input='${hello1}'"
57 )
58 assert "Hello, world!" in docker.succeed(
59 "docker run --rm ${hello1.imageName} hello",
60 )
61 docker.succeed(
62 "docker rmi ${hello1.imageName}",
63 )
64
65 with subtest("Ensure cross compiled buildLayeredImage image can run."):
66 docker.succeed(
67 "docker load --input='${hello2}'"
68 )
69 assert "Hello, world!" in docker.succeed(
70 "docker run --rm ${hello2.imageName} hello",
71 )
72 docker.succeed(
73 "docker rmi ${hello2.imageName}",
74 )
75 '';
76})