Skip to content

Commit

Permalink
feat(ci): Code coverage for integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
vifino committed Feb 9, 2024
1 parent 659af66 commit c374e77
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ jobs:
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Run Flake Check
run: nix build -L .#checks.${{ matrix.system }}-linux.${{ matrix.check }}
- name: Copy coverage to current directory
run: cp $(nix eval --raw .#checks.${{ matrix.system }}-linux.${{ matrix.check }})/nvmet.lcov .
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
file: nvmet.lcov
name: ${{ matrix.system }}-${{ matrix.check }}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
packages = rec {
nvmetcfg = pkgs.callPackage ./. {};
nvmetcfg-static = pkgs.pkgsStatic.callPackage ./. {};
nvmetcfg-coverage = (nvmetcfg.overrideAttrs (o: { RUSTFLAGS = "-C instrument-coverage"; dontStrip = true; }));
default = nvmetcfg;
};
devShells.default = pkgs.mkShell {
Expand Down
13 changes: 12 additions & 1 deletion tests/loop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
system,
...
}: {
environment.systemPackages = [self.packages.${system}.default pkgs.nvme-cli];
environment.systemPackages = with pkgs; [
self.packages.${system}.nvmetcfg-coverage nvme-cli
llvmPackages_latest.bintools
];
boot.kernelModules = ["nvmet"];
virtualisation.diskSize = 4096;
environment.variables.LLVM_PROFILE_FILE = "/tmp/nvmetcfg-%p-%8m.profraw";
};
testScript = let
subnqn = "nqn.2023-11.sh.tty:nvmetcfg-test-loop";
Expand Down Expand Up @@ -64,5 +68,12 @@
node.succeed("nvmet port remove 1")
node.fail("test -e /sys/kernel/config/nvmet/ports/1")
# Export coverage.
node.succeed("llvm-profdata merge --sparse -o /tmp/nvmetcfg.profdata /tmp/nvmetcfg-*.profraw")
node.succeed("llvm-cov export -format=lcov -instr-profile=/tmp/nvmetcfg.profdata " +
"--ignore-filename-regex=/.cargo/registry --show-instantiation-summary " +
"-object $(which nvmet) > /tmp/nvmet.lcov")
node.copy_from_vm("/tmp/nvmet.lcov")
'';
}
13 changes: 12 additions & 1 deletion tests/rdma.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
system,
...
}: {
environment.systemPackages = [self.packages.${system}.default];
environment.systemPackages = with pkgs; [
self.packages.${system}.nvmetcfg-coverage
llvmPackages_latest.bintools
];
boot.kernelModules = ["nvmet" "nvmet_rdma" "rdma_rxe"];
virtualisation.diskSize = 4096;
networking.rxe.enable = true;
networking.rxe.interfaces = ["eth1"];
networking.firewall.allowedUDPPorts = [4791];
environment.variables.LLVM_PROFILE_FILE = "/tmp/nvmetcfg-%p-%8m.profraw";
};
initiator = {
self,
Expand Down Expand Up @@ -88,5 +92,12 @@
target.succeed("nvmet port remove 1")
target.fail("test -e /sys/kernel/config/nvmet/ports/1")
# Export coverage.
node.succeed("llvm-profdata merge --sparse -o /tmp/nvmetcfg.profdata /tmp/nvmetcfg-*.profraw")
node.succeed("llvm-cov export -format=lcov -instr-profile=/tmp/nvmetcfg.profdata " +
"--ignore-filename-regex=/.cargo/registry --show-instantiation-summary " +
"-object $(which nvmet) > /tmp/nvmet.lcov")
node.copy_from_vm("/tmp/nvmet.lcov")
'';
}
13 changes: 12 additions & 1 deletion tests/tcp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
system,
...
}: {
environment.systemPackages = [self.packages.${system}.default];
environment.systemPackages = with pkgs; [
self.packages.${system}.nvmetcfg-coverage
llvmPackages_latest.bintools
];
boot.kernelModules = ["nvmet" "nvmet_tcp"];
virtualisation.diskSize = 4096;
networking.firewall.allowedTCPPorts = [4420];
environment.variables.LLVM_PROFILE_FILE = "/tmp/nvmetcfg-%p-%8m.profraw";
};
initiator = {
self,
Expand Down Expand Up @@ -81,5 +85,12 @@
target.succeed("nvmet port remove 1")
target.fail("test -e /sys/kernel/config/nvmet/ports/1")
# Export coverage.
node.succeed("llvm-profdata merge --sparse -o /tmp/nvmetcfg.profdata /tmp/nvmetcfg-*.profraw")
node.succeed("llvm-cov export -format=lcov -instr-profile=/tmp/nvmetcfg.profdata " +
"--ignore-filename-regex=/.cargo/registry --show-instantiation-summary " +
"-object $(which nvmet) > /tmp/nvmet.lcov")
node.copy_from_vm("/tmp/nvmet.lcov")
'';
}

0 comments on commit c374e77

Please sign in to comment.