From a81f653778b155f0f5c560c2c8496c19222ac036 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Wed, 10 Jul 2024 11:49:29 +0200 Subject: [PATCH] WIP: tests/emulator/test_channels_shell: investigate what happens to $PATH --- modules/environment/login/login-inner.nix | 2 ++ modules/environment/login/login.nix | 2 ++ tests/emulator/test_channels_shell.py | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/environment/login/login-inner.nix b/modules/environment/login/login-inner.nix index cb929ddb..de8c6d7d 100644 --- a/modules/environment/login/login-inner.nix +++ b/modules/environment/login/login-inner.nix @@ -13,6 +13,8 @@ writeText "login-inner" '' set -eo pipefail + echo login-inner PATH=$PATH + ${lib.optionalString (config.environment.motd != null) '' if [ "$#" -eq 0 ]; then # if script is called from within Nix-on-Droid app echo "${lib.removeSuffix "\n" config.environment.motd}" diff --git a/modules/environment/login/login.nix b/modules/environment/login/login.nix index 4052d73e..4180b2c0 100644 --- a/modules/environment/login/login.nix +++ b/modules/environment/login/login.nix @@ -17,6 +17,8 @@ writeScript "login" '' # This file is generated by Nix-on-Droid. DO NOT EDIT. set -eu -o pipefail + echo login PATH=$PATH + export USER="${config.user.userName}" export HOME="${config.user.home}" export PROOT_TMP_DIR=${installationDir}/tmp diff --git a/tests/emulator/test_channels_shell.py b/tests/emulator/test_channels_shell.py index 5e2f925e..5a47f936 100644 --- a/tests/emulator/test_channels_shell.py +++ b/tests/emulator/test_channels_shell.py @@ -31,13 +31,25 @@ def run(d): 'id', f'mkdir -p {STD}', f'touch {STD}/confirmation-granted', + 'echo $PATH', + 'env -i env', '/data/data/com.termux.nix/files/usr/bin/login echo test', '/data/data/com.termux.nix/files/usr/bin/login id', ('cd /data/data/com.termux.nix/files/home; ' 'pwd; ' 'id; ' '/data/data/com.termux.nix/files/usr/bin/login ' - ' nix-on-droid on-device-test') + ' env'), + ('cd /data/data/com.termux.nix/files/home; ' + 'pwd; ' + 'id; ' + 'env -i PATH= /data/data/com.termux.nix/files/usr/bin/login ' + ' env'), + ('cd /data/data/com.termux.nix/files/home; ' + 'pwd; ' + 'id; ' + 'env -i PATH= /data/data/com.termux.nix/files/usr/bin/login ' + ' nix-on-droid on-device-test'), ]: print(f'running {cmd} as {user} with capture:') p = subprocess.Popen(['adb', 'shell', 'su', '0', 'su', user,