-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathconfig-flake-hosts.bats
37 lines (31 loc) · 1.21 KB
/
config-flake-hosts.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) 2023, see AUTHORS. Licensed under MIT License, see LICENSE.
load lib
@test 'hosts can be configured' {
# set up / build / activate the configuration
cat "$ON_DEVICE_TESTS_DIR/config-flake-hosts.cfg.nix" \
> ~/.config/nixpkgs/nix-on-droid.nix
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
> ~/.config/nixpkgs/flake.nix
nix-on-droid switch --flake ~/.config/nixpkgs#device
# check that /etc/hosts contains configured hosts
for entry in '::1 localhost' \
'127.0.0.1 localhost' \
'127.0.0.2 a b' \
'127.0.0.3 c' \
'127.0.0.4 d'
do
grep "$entry" /etc/hosts
done
}
@test 'hosts can not map localhost' {
# set up / build / activate the configuration
cat "$ON_DEVICE_TESTS_DIR/config-flake-hosts-localhost.cfg.nix" \
> ~/.config/nixpkgs/nix-on-droid.nix
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
> ~/.config/nixpkgs/flake.nix
# check that networking.hosts can't map localhost
run nix-on-droid switch --flake ~/.config/nixpkgs#device
[ "$status" -eq 1 ]
}