testing around with proot

This commit is contained in:
Michael Zhang 2021-09-05 22:40:22 -05:00
parent dc68851233
commit 9b17ba5fee
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
6 changed files with 36 additions and 5 deletions

View file

@ -8,5 +8,5 @@ charset = utf-8
indent_style = space
indent_size = 4
[*.nix]
[*.{nix,sh}]
indent_size = 2

View file

@ -8,6 +8,7 @@
let
pkgs = nixpkgs.legacyPackages.${system};
garbageProj = import ./Cargo.nix { inherit pkgs; };
garbageProjDebug = import ./Cargo.nix { inherit pkgs; release = false; };
garbage = pkgs.lib.recursiveUpdate garbageProj.rootCrate.build {
meta = {
description = "CLI tool to interact with the FreeDesktop trash API.";
@ -16,7 +17,7 @@
};
flakePkgs = {
inherit garbage;
tests = pkgs.callPackage ./tests { inherit garbage; };
tests = pkgs.callPackage ./tests { garbage = garbageProjDebug.rootCrate.build; };
};
in
rec {

1
tests/.common.sh Normal file
View file

@ -0,0 +1 @@
export RUST_BACKTRACE=1

View file

@ -1,4 +1,4 @@
{ stdenv, garbage }:
{ stdenv, garbage, pkgs }:
stdenv.mkDerivation {
name = "garbage-tests";
@ -7,7 +7,8 @@ stdenv.mkDerivation {
installPhase = "mkdir -p $out";
doCheck = true;
garbage = "${garbage}/bin/garbage";
buildInputs = with pkgs; [ garbage proot mktemp mount which bash ];
checkPhase = ''
find . -executable -name "*.sh" | xargs bash
'';

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
source .common.sh
filename=$'\377'$'\017'$'\224'$'\353'\`$'\001'
touch $filename
$garbage put $filename
garbage put $filename

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
source .common.sh
garbage=$(which garbage)
tmproot=$(mktemp -d)
mkdir -p $tmproot/{mnt,home}
echo "delete" > $tmproot/mnt/mnt-delete
echo "delete" > touch $tmproot/home/home-delete
cat > $tmproot/run.sh << EOF
cd /mnt
ls -al
cat mnt-delete
garbage put mnt-delete
garbage list
EOF
chmod +x $tmproot/run.sh
proot \
-0 \
-r $tmproot \
-b /bin \
-b /nix \
-w / \
--kill-on-exit \
"/run.sh"