diff --git a/.github/workflows/build2.yaml b/.github/workflows/build2.yaml index 2dc5b1b..c9f1cf9 100644 --- a/.github/workflows/build2.yaml +++ b/.github/workflows/build2.yaml @@ -37,6 +37,10 @@ jobs: ls -la $GITHUB_WORKSPACE cat /tmp/entrypoint-env.txt || true + - name: Memory Test + run: | + $MEMORYTEST + - name: Reuse Lint run: | nix run .#reuse-lint diff --git a/build.zig b/build.zig index 309fa87..ff91db4 100644 --- a/build.zig +++ b/build.zig @@ -91,85 +91,116 @@ pub fn build(b: *std.Build) !void { options.addOption([]const u8, "bash", bash); options.addOption([]const u8, "sh", sh); - const execas_exe = b.addExecutable(.{ - .name = b.fmt("execas-{d}", .{uid}), - .root_module = b.createModule(.{ - .root_source_file = b.path("src/execas.zig"), - .target = target, - .optimize = optimize, - }), - .use_llvm = false, - .use_lld = false, - }); - execas_exe.root_module.addOptions("options", options); - b.installArtifact(execas_exe); - - const execas_tests = b.addTest(.{ - .root_module = execas_exe.root_module, - }); - const run_execas_tests = b.addRunArtifact(execas_tests); - test_step.dependOn(&run_execas_tests.step); - - const tail_exe = b.addExecutable(.{ - .name = "tail", - .root_module = b.createModule(.{ - .root_source_file = b.path("src/tail.zig"), - .target = target, - .optimize = optimize, - }), - .use_llvm = false, - .use_lld = false, - }); - tail_exe.root_module.addOptions("options", options); - - b.installArtifact(tail_exe); - - const tail_tests = b.addTest(.{ - .root_module = tail_exe.root_module, - }); - - const run_tail_tests = b.addRunArtifact(tail_tests); - test_step.dependOn(&run_tail_tests.step); - - const bash_exe = b.addExecutable(.{ - .name = "bash", - .root_module = b.createModule(.{ - .root_source_file = b.path("src/bash.zig"), - .target = target, - .optimize = optimize, - }), - .use_llvm = false, - .use_lld = false, - }); - bash_exe.root_module.addOptions("options", options); - - b.installArtifact(bash_exe); - - const bash_tests = b.addTest(.{ - .root_module = bash_exe.root_module, - }); + { + const execas_exe = b.addExecutable(.{ + .name = b.fmt("execas-{d}", .{uid}), + .root_module = b.createModule(.{ + .root_source_file = b.path("src/execas.zig"), + .target = target, + .optimize = optimize, + }), + .use_llvm = false, + .use_lld = false, + }); + execas_exe.root_module.addOptions("options", options); + b.installArtifact(execas_exe); + + const execas_tests = b.addTest(.{ + .root_module = execas_exe.root_module, + }); + const run_execas_tests = b.addRunArtifact(execas_tests); + test_step.dependOn(&run_execas_tests.step); + } - const run_bash_tests = b.addRunArtifact(bash_tests); - test_step.dependOn(&run_bash_tests.step); - - const sh_exe = b.addExecutable(.{ - .name = "sh", - .root_module = b.createModule(.{ - .root_source_file = b.path("src/sh.zig"), - .target = target, - .optimize = optimize, - }), - .use_llvm = false, - .use_lld = false, - }); - sh_exe.root_module.addOptions("options", options); + { + const tail_exe = b.addExecutable(.{ + .name = "tail", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/tail.zig"), + .target = target, + .optimize = optimize, + }), + .use_llvm = false, + .use_lld = false, + }); + tail_exe.root_module.addOptions("options", options); + + b.installArtifact(tail_exe); + + const tail_tests = b.addTest(.{ + .root_module = tail_exe.root_module, + }); + + const run_tail_tests = b.addRunArtifact(tail_tests); + test_step.dependOn(&run_tail_tests.step); + } - b.installArtifact(sh_exe); + { + const bash_exe = b.addExecutable(.{ + .name = "bash", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/bash.zig"), + .target = target, + .optimize = optimize, + }), + .use_llvm = false, + .use_lld = false, + }); + bash_exe.root_module.addOptions("options", options); + + b.installArtifact(bash_exe); + + const bash_tests = b.addTest(.{ + .root_module = bash_exe.root_module, + }); + + const run_bash_tests = b.addRunArtifact(bash_tests); + test_step.dependOn(&run_bash_tests.step); + } - const sh_tests = b.addTest(.{ - .root_module = sh_exe.root_module, - }); + { + const sh_exe = b.addExecutable(.{ + .name = "sh", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/sh.zig"), + .target = target, + .optimize = optimize, + }), + .use_llvm = false, + .use_lld = false, + }); + sh_exe.root_module.addOptions("options", options); + + b.installArtifact(sh_exe); + + const sh_tests = b.addTest(.{ + .root_module = sh_exe.root_module, + }); + + const run_sh_tests = b.addRunArtifact(sh_tests); + test_step.dependOn(&run_sh_tests.step); + } - const run_sh_tests = b.addRunArtifact(sh_tests); - test_step.dependOn(&run_sh_tests.step); + { + const memorytest_exe = b.addExecutable(.{ + .name = "memorytest", + .root_module = b.createModule(.{ + .root_source_file = b.path("src/memorytest.zig"), + .target = target, + .optimize = optimize, + }), + .use_llvm = false, + .use_lld = false, + }); + memorytest_exe.root_module.addOptions("options", options); + + b.installArtifact(memorytest_exe); + + const memorytest_tests = b.addTest(.{ + .root_module = memorytest_exe.root_module, + }); + + const run_memorytest_tests = b.addRunArtifact(memorytest_tests); + test_step.dependOn(&run_memorytest_tests.step); + } } diff --git a/flake.nix b/flake.nix index 1076a41..04fe615 100644 --- a/flake.nix +++ b/flake.nix @@ -517,8 +517,6 @@ { Cmd = [ "${lib.getExe' execas-github "bash"}" ]; User = "0:0"; - # WorkingDir = "/github/home"; - # Entrypoint = [ "${lib.getExe entrypoint}" ]; Env = [ "USER=root" "PATH=${ @@ -545,6 +543,7 @@ "GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" "NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" "NIX_PATH=/nix/var/nix/profiles/per-user/root/channels:/root/home/.nix-defexpr/channels" + "MEMORYTEST=${lib.getExe' execas-github "memorytest"}" ]; }; }; diff --git a/src/memorytest.zig b/src/memorytest.zig new file mode 100644 index 0000000..6595135 --- /dev/null +++ b/src/memorytest.zig @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: © 2023 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + +const std = @import("std"); + +pub fn main(init: std.process.Init) !void { + const alloc: std.mem.Allocator = init.arena.allocator(); + while (true) { + _ = try alloc.alloc(u8, 1024 * 1024); + std.debug.print("Capacity: {Bi}\n", .{init.arena.queryCapacity()}); + } +}