Browse Source

Merge branch 'master' into regenerate_all

master
Daniel Molkentin 5 years ago committed by GitHub
parent
commit
5b1d8bcc58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      .github/workflows/fedora-30.yml
  2. 54
      .github/workflows/fedora-31.yml
  3. 13
      .travis.yml
  4. 2
      Makefile
  5. 2
      README.md
  6. 2
      dracut-init.sh
  7. 4
      dracut.8.asc
  8. 3
      dracut.cmdline.7.asc
  9. 3
      dracut.conf.5.asc
  10. 22
      dracut.sh
  11. 40
      fedora-test-github.sh
  12. 42
      fedora-test.sh
  13. 44
      install/dracut-install.c
  14. 2
      lsinitrd.sh
  15. 2
      modules.d/00systemd/module-setup.sh
  16. 22
      modules.d/35network-legacy/ifup.sh
  17. 4
      modules.d/35network-legacy/net-genrules.sh
  18. 6
      modules.d/40network/net-lib.sh
  19. 4
      modules.d/80cms/cmssetup.sh
  20. 2
      modules.d/90stratis/module-setup.sh
  21. 8
      modules.d/95fcoe/fcoe-genrules.sh
  22. 8
      modules.d/95nbd/parse-nbdroot.sh
  23. 2
      test/TEST-01-BASIC/create-root.sh
  24. 2
      test/TEST-01-BASIC/test-init.sh
  25. 96
      test/TEST-01-BASIC/test.sh
  26. 2
      test/TEST-02-SYSTEMD/create-root.sh
  27. 2
      test/TEST-02-SYSTEMD/test-init.sh
  28. 38
      test/TEST-02-SYSTEMD/test.sh
  29. 7
      test/TEST-03-USR-MOUNT/create-root.sh
  30. 2
      test/TEST-03-USR-MOUNT/test-init.sh
  31. 123
      test/TEST-03-USR-MOUNT/test.sh
  32. 6
      test/TEST-04-FULL-SYSTEMD/create-root.sh
  33. 23
      test/TEST-04-FULL-SYSTEMD/test-init.sh
  34. 169
      test/TEST-04-FULL-SYSTEMD/test.sh
  35. 2
      test/TEST-10-RAID/create-root.sh
  36. 2
      test/TEST-10-RAID/test-init.sh
  37. 92
      test/TEST-10-RAID/test.sh
  38. 2
      test/TEST-11-LVM/create-root.sh
  39. 2
      test/TEST-11-LVM/test-init.sh
  40. 85
      test/TEST-11-LVM/test.sh
  41. 10
      test/TEST-12-RAID-DEG/create-root.sh
  42. 2
      test/TEST-12-RAID-DEG/hard-off.sh
  43. 2
      test/TEST-12-RAID-DEG/test-init.sh
  44. 37
      test/TEST-12-RAID-DEG/test.sh
  45. 2
      test/TEST-13-ENC-RAID-LVM/create-root.sh
  46. 2
      test/TEST-13-ENC-RAID-LVM/test-init.sh
  47. 117
      test/TEST-13-ENC-RAID-LVM/test.sh
  48. 2
      test/TEST-14-IMSM/create-root.sh
  49. 2
      test/TEST-14-IMSM/test-init.sh
  50. 104
      test/TEST-14-IMSM/test.sh
  51. 2
      test/TEST-15-BTRFSRAID/create-root.sh
  52. 2
      test/TEST-15-BTRFSRAID/test-init.sh
  53. 90
      test/TEST-15-BTRFSRAID/test.sh
  54. 2
      test/TEST-16-DMSQUASH/test-init.sh
  55. 94
      test/TEST-16-DMSQUASH/test.sh
  56. 2
      test/TEST-17-LVM-THIN/create-root.sh
  57. 2
      test/TEST-17-LVM-THIN/test-init.sh
  58. 85
      test/TEST-17-LVM-THIN/test.sh
  59. 2
      test/TEST-20-NFS/client-init.sh
  60. 46
      test/TEST-20-NFS/server-init.sh
  61. 121
      test/TEST-20-NFS/test.sh
  62. 12
      test/TEST-21-NFS-NM/Makefile
  63. 2
      test/TEST-30-ISCSI/client-init.sh
  64. 2
      test/TEST-30-ISCSI/create-root.sh
  65. 24
      test/TEST-30-ISCSI/server-init.sh
  66. 115
      test/TEST-30-ISCSI/test.sh
  67. 12
      test/TEST-31-ISCSI-NM/Makefile
  68. 0
      test/TEST-35-ISCSI-MULTI/99-idesymlinks.rules
  69. 0
      test/TEST-35-ISCSI-MULTI/Makefile
  70. 2
      test/TEST-35-ISCSI-MULTI/client-init.sh
  71. 2
      test/TEST-35-ISCSI-MULTI/create-root.sh
  72. 0
      test/TEST-35-ISCSI-MULTI/dhcpd.conf
  73. 0
      test/TEST-35-ISCSI-MULTI/finished-false.sh
  74. 0
      test/TEST-35-ISCSI-MULTI/hard-off.sh
  75. 0
      test/TEST-35-ISCSI-MULTI/hosts
  76. 52
      test/TEST-35-ISCSI-MULTI/server-init.sh
  77. 125
      test/TEST-35-ISCSI-MULTI/test.sh
  78. 12
      test/TEST-36-ISCSI-MULTI-NM/Makefile
  79. 2
      test/TEST-40-NBD/client-init.sh
  80. 2
      test/TEST-40-NBD/create-root.sh
  81. 38
      test/TEST-40-NBD/server-init.sh
  82. 167
      test/TEST-40-NBD/test.sh
  83. 12
      test/TEST-41-NBD-NM/Makefile
  84. 2
      test/TEST-50-MULTINIC/client-init.sh
  85. 11
      test/TEST-50-MULTINIC/server-init.sh
  86. 74
      test/TEST-50-MULTINIC/test.sh
  87. 12
      test/TEST-51-MULTINIC-NM/Makefile
  88. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/99-default.link
  89. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/99-idesymlinks.rules
  90. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/Makefile
  91. 6
      test/TEST-60-BONDBRIDGEVLANIFCFG/client-init.sh
  92. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/dhcpd.conf
  93. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/exports
  94. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/finished-false.sh
  95. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/hard-off.sh
  96. 0
      test/TEST-60-BONDBRIDGEVLANIFCFG/hosts
  97. 62
      test/TEST-60-BONDBRIDGEVLANIFCFG/server-init.sh
  98. 156
      test/TEST-60-BONDBRIDGEVLANIFCFG/test.sh
  99. 12
      test/TEST-61-BONDBRIDGEVLANIFCFG-NM/Makefile
  100. 6
      test/TEST-70-BONDBRIDGETEAMVLAN/99-default.link
  101. Some files were not shown because too many files have changed in this diff Show More

48
.github/workflows/fedora-30.yml

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
## The test container is created with https://github.com/dracutdevs/fedora-container

name: Fedora-30

on:
push:
branches:
- 'master'
tags:
- '*'
pull_request:

jobs:
test:
runs-on: ubuntu-latest
#container: quay.io/haraldh/dracut-fedora:30
timeout-minutes: 30
strategy:
matrix:
test: [
"01",
"02",
"03",
"04",
"10",
"11",
"12",
"13",
"14",
"15",
"17",
"20",
"30",
"35",
"40",
"50",
"60",
"99",
]
fail-fast: false
steps:
- name: "Checkout Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "TEST-${{ matrix.test }}"
run: docker run --privileged -v $(pwd)/:/dracut quay.io/haraldh/dracut-fedora:30 /dracut/fedora-test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }}

54
.github/workflows/fedora-31.yml

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
## The test container is created with https://github.com/dracutdevs/fedora-container

name: Fedora-31

on:
push:
branches:
- 'master'
tags:
- '*'
pull_request:

jobs:
test:
runs-on: ubuntu-latest
#container: quay.io/haraldh/dracut-fedora:30
timeout-minutes: 30
strategy:
matrix:
test: [
"01",
"02",
"03",
"04",
"10",
"11",
"12",
"13",
"14",
"15",
"17",
"20",
"21",
"30",
"31",
"35",
"36",
"40",
"41",
"50",
"51",
"60",
"61",
"99",
]
fail-fast: false
steps:
- name: "Checkout Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "TEST-${{ matrix.test }}"
run: docker run --privileged -v $(pwd)/:/dracut quay.io/haraldh/dracut-fedora:31 /dracut/fedora-test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }}

13
.travis.yml

@ -9,11 +9,17 @@ env: @@ -9,11 +9,17 @@ env:
- IMAGE=latest TESTS=01
- IMAGE=latest TESTS=12
- IMAGE=latest TESTS=20
- IMAGE=latest TESTS=21
- IMAGE=latest TESTS=50
- IMAGE=latest TESTS=51
- IMAGE=latest TESTS=30
- IMAGE=latest TESTS=31
- IMAGE=latest TESTS=35
- IMAGE=latest TESTS=36
- IMAGE=latest TESTS=40
- IMAGE=latest TESTS=41
- IMAGE=latest TESTS=60
- IMAGE=latest TESTS=70
- IMAGE=latest TESTS=61
- IMAGE=latest TESTS=99
- IMAGE=latest TESTS=02
- IMAGE=latest TESTS=03
@ -26,7 +32,7 @@ env: @@ -26,7 +32,7 @@ env:
- IMAGE=latest TESTS=17

before_script:
- docker pull fedora:$IMAGE
- docker pull quay.io/haraldh/dracut-fedora:$IMAGE
- |
sudo modprobe kvm-intel nested=1 || :
sudo modprobe kvm-amd nested=1 || :
@ -37,7 +43,8 @@ before_script: @@ -37,7 +43,8 @@ before_script:
git describe --tags || :

script:
- docker run --privileged -it -v $(pwd)/:/dracut fedora:$IMAGE /dracut/fedora-test.sh $IMAGE-$$ "$TESTS"
## The test container is created with https://github.com/dracutdevs/fedora-container
- docker run --privileged -it -v $(pwd)/:/dracut quay.io/haraldh/dracut-fedora:$IMAGE /dracut/fedora-test.sh $IMAGE-$$ "$TESTS"

notifications:
webhooks:

2
Makefile

@ -210,7 +210,7 @@ dracut-$(DRACUT_MAIN_VERSION).tar.xz: doc syncheck @@ -210,7 +210,7 @@ dracut-$(DRACUT_MAIN_VERSION).tar.xz: doc syncheck
rm -f -- dracut-$(DRACUT_MAIN_VERSION).tar

rpm: dracut-$(DRACUT_MAIN_VERSION).tar.xz syncheck
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
rpmbuild=$$(mktemp -d -p /var/tmp rpmbuild-dracut.XXXXXX); src=$$(pwd); \
cp dracut-$(DRACUT_MAIN_VERSION).tar.xz "$$rpmbuild"; \
LC_MESSAGES=C $$src/git2spec.pl $(DRACUT_MAIN_VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
(cd "$$rpmbuild"; \

2
README.md

@ -4,6 +4,8 @@ dracut @@ -4,6 +4,8 @@ dracut
dracut is an event driven initramfs infrastructure.

[![Build Status](https://travis-ci.org/dracutdevs/dracut.svg?branch=master)](https://travis-ci.org/dracutdevs/dracut)
![Fedora-30](https://github.com/dracutdevs/dracut/workflows/Fedora-30/badge.svg?branch=master)
![Fedora-31](https://github.com/dracutdevs/dracut/workflows/Fedora-31/badge.svg?branch=master)

dracut (the tool) is used to create an initramfs image by copying tools
and files from an installed system and combining it with the

2
dracut-init.sh

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
#
export LC_MESSAGES=C

if [[ "$EUID" = "0" ]]; then
if [[ "$EUID" = "0" ]] && ! [[ $DRACUT_NO_XATTR ]]; then
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
else
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"

4
dracut.8.asc

@ -517,6 +517,10 @@ will not be able to boot. @@ -517,6 +517,10 @@ will not be able to boot.
_$prefix/lib/systemd/boot/efi/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_
or _$prefix/lib/gummiboot/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_

**--uefi-splash-image _<FILE>_**::
Specifies the UEFI stub loader's splash image. Requires bitmap (**.bmp**) image
format.

**--kernel-image _<FILE>_**::
Specifies the kernel image, which to include in the UEFI executable. The default is
_/lib/modules/<KERNEL-VERSION>/vmlinuz_ or _/boot/vmlinuz-<KERNEL-VERSION>_

3
dracut.cmdline.7.asc

@ -786,6 +786,9 @@ iscsistart -b --param node.session.timeo.replacement_timeout=30 @@ -786,6 +786,9 @@ iscsistart -b --param node.session.timeo.replacement_timeout=30
**rd.iscsi.ibft** **rd.iscsi.ibft=1**:
Turn on iBFT autoconfiguration for the interfaces

**rd.iscsi.mp** **rd.iscsi.mp=1**:
Configure all iBFT interfaces, not only used for booting (multipath)

**rd.iscsi.waitnet=0**:
Turn off waiting for all interfaces to be up before trying to login to the iSCSI targets.


3
dracut.conf.5.asc

@ -205,6 +205,9 @@ provide a valid _/etc/fstab_. @@ -205,6 +205,9 @@ provide a valid _/etc/fstab_.
_/lib/systemd/boot/efi/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_
or _/usr/lib/gummiboot/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_

*uefi_splash_image=*"_<FILE>_"::
Specifies the UEFI stub loader's splash image. Requires bitmap (**.bmp**) image format.

*uefi_secureboot_cert=*"_<FILE>_", *uefi_secureboot_key=*"_<FILE>_"::
Specifies a certificate and corresponding key, which are used to sign the created UEFI executable.
Requires both certificate and key need to be specified and _sbsign_ to be installed.

22
dracut.sh

@ -236,7 +236,10 @@ Creates initial ramdisk images for preloading modules @@ -236,7 +236,10 @@ Creates initial ramdisk images for preloading modules
--uefi Create an UEFI executable with the kernel cmdline and
kernel combined
--uefi-stub [FILE] Use the UEFI stub [FILE] to create an UEFI executable
--kernel-image [FILE] Location of the kernel image
--uefi-splash-image [FILE]
Use [FILE] as a splash image when creating an UEFI
executable
--kernel-image [FILE] location of the kernel image
--regenerate-all Regenerate all initramfs images at the default location
for the kernel versions found on the system

@ -400,6 +403,7 @@ rearrange_params() @@ -400,6 +403,7 @@ rearrange_params()
--long loginstall: \
--long uefi \
--long uefi-stub: \
--long uefi-splash-image: \
--long kernel-image: \
--long no-hostonly-i18n \
--long hostonly-i18n \
@ -598,6 +602,8 @@ while :; do @@ -598,6 +602,8 @@ while :; do
--uefi) uefi="yes";;
--uefi-stub)
uefi_stub_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--uefi-splash-image)
uefi_splash_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--kernel-image)
kernel_image_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--no-machineid)
@ -774,6 +780,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l)) @@ -774,6 +780,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
[[ $reproducible_l ]] && reproducible="$reproducible_l"
[[ $loginstall_l ]] && loginstall="$loginstall_l"
[[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
[[ $uefi_splash_image_l ]] && uefi_splash_image="$uefi_splash_image_l"
[[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
[[ $machine_id_l ]] && machine_id="$machine_id_l"

@ -940,6 +947,12 @@ readonly TMPDIR="$(realpath -e "$tmpdir")" @@ -940,6 +947,12 @@ readonly TMPDIR="$(realpath -e "$tmpdir")"
printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2
exit 1
}

if findmnt --raw -n --target "$tmpdir" --output=options | grep -q noexec; then
[[ $debug == yes ]] && printf "%s\n" "dracut: Tmpdir '$tmpdir' is mounted with 'noexec'."
noexec=1
fi

readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
[ -d "$DRACUT_TMPDIR" ] || {
printf "%s\n" "dracut: mktemp -p '$TMPDIR/' -d -t dracut.XXXXXX failed." >&2
@ -964,7 +977,7 @@ if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_t @@ -964,7 +977,7 @@ if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_t
mkdir "$early_cpio_dir"
fi

[[ -n "$dracutsysrootdir" ]] || export DRACUT_RESOLVE_LAZY="1"
[[ -n "$dracutsysrootdir" || "$noexec" ]] || export DRACUT_RESOLVE_LAZY="1"

if [[ $print_cmdline ]]; then
stdloglvl=0
@ -2020,11 +2033,14 @@ if [[ $uefi = yes ]]; then @@ -2020,11 +2033,14 @@ if [[ $uefi = yes ]]; then

[[ -s $dracutsysrootdir/usr/lib/os-release ]] && uefi_osrelease="$dracutsysrootdir/usr/lib/os-release"
[[ -s $dracutsysrootdir/etc/os-release ]] && uefi_osrelease="$dracutsysrootdir/etc/os-release"
[[ -s "${dracutsysrootdir}${uefi_splash_image}" ]] && \
uefi_splash_image="${dracutsysroot}${uefi_splash_image}" || unset uefi_splash_image

if objcopy \
${uefi_osrelease:+--add-section .osrel=$uefi_osrelease --change-section-vma .osrel=0x20000} \
--add-section .cmdline="${uefi_outdir}/cmdline.txt" --change-section-vma .cmdline=0x30000 \
--add-section .linux="$kernel_image" --change-section-vma .linux=0x40000 \
${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=0x40000} \
--add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \
--add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd=0x3000000 \
"$uefi_stub" "${uefi_outdir}/linux.efi"; then
if [[ -n "${uefi_secureboot_key}" && -n "${uefi_secureboot_cert}" ]]; then \

40
fedora-test-github.sh

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
#!/bin/bash

set -ex

[[ -d ${0%/*} ]] && cd ${0%/*}

RUN_ID="$1"
TESTS=$2

# GitHub workflows fetch a clone of the dracut repository which doesn't
# contain git tags, thus "breaking" the RPM build in certain situations
# i.e.:
# DRACUT_MAIN_VERSION in Makefile is defined as an output of `git describe`,
# which in full git clone returns a tag with a numeric version. However,
# without tags it returns SHA of the last commit, which later propagates into
# `Provides:` attribute of the built RPM and can break dependency tree when
# installed
[[ -d .git ]] && git fetch --tags && git describe --tags

./configure

NCPU=$(getconf _NPROCESSORS_ONLN)

if ! [[ $TESTS ]]; then
make -j$NCPU all syncheck rpm logtee
else
[[ $TESTS == "99" ]] && make_docs=yes || make_docs=no
make -j$NCPU enable_documentation=$make_docs all logtee

cd test

time LOGTEE_TIMEOUT_MS=590000 make \
enable_documentation=$make_docs \
KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
DRACUT_NO_XATTR=1 \
TEST_RUN_ID=$RUN_ID \
${TESTS:+TESTS="$TESTS"} \
-k V=1 \
check
fi

42
fedora-test.sh

@ -7,41 +7,6 @@ set -ex @@ -7,41 +7,6 @@ set -ex
RUN_ID="$1"
TESTS=$2

dnf -y update --best --allowerasing &>/dev/null

dnf -y install --best --allowerasing \
dash \
asciidoc \
mdadm \
lvm2 \
dmraid \
cryptsetup \
nfs-utils \
nbd \
dhcp-server \
scsi-target-utils \
iscsi-initiator-utils \
strace \
btrfs-progs \
kmod-devel \
gcc \
bzip2 \
xz \
tar \
wget \
rpm-build \
make \
git \
bash-completion \
sudo \
kernel \
dhcp-client \
/usr/bin/qemu-kvm \
/usr/bin/qemu-system-$(uname -i) \
e2fsprogs \
tcpdump \
$NULL &>/dev/null

./configure

NCPU=$(getconf _NPROCESSORS_ONLN)
@ -49,12 +14,15 @@ NCPU=$(getconf _NPROCESSORS_ONLN) @@ -49,12 +14,15 @@ NCPU=$(getconf _NPROCESSORS_ONLN)
if ! [[ $TESTS ]]; then
make -j$NCPU all syncheck rpm logtee
else
make -j$NCPU all logtee
[[ $TESTS == "99" ]] && make_docs=yes || make_docs=no
make -j$NCPU enable_documentation=$make_docs all logtee

cd test

time sudo LOGTEE_TIMEOUT_MS=590000 make \
time sudo LOGTEE_TIMEOUT_MS=300000 make \
enable_documentation=$make_docs \
KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
DRACUT_NO_XATTR=1 \
TEST_RUN_ID=$RUN_ID \
${TESTS:+TESTS="$TESTS"} \
-k V=2 \

44
install/dracut-install.c

@ -59,6 +59,7 @@ static bool arg_modalias = false; @@ -59,6 +59,7 @@ static bool arg_modalias = false;
static bool arg_resolvelazy = false;
static bool arg_resolvedeps = false;
static bool arg_hostonly = false;
static bool no_xattr = false;
static char *destrootdir = NULL;
static char *sysrootdir = NULL;
static size_t sysrootdirlen = 0;
@ -310,7 +311,7 @@ static int cp(const char *src, const char *dst) @@ -310,7 +311,7 @@ static int cp(const char *src, const char *dst)
normal_copy:
pid = fork();
if (pid == 0) {
if (geteuid() == 0)
if (geteuid() == 0 && no_xattr == false)
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst,
NULL);
else
@ -322,7 +323,7 @@ static int cp(const char *src, const char *dst) @@ -322,7 +323,7 @@ static int cp(const char *src, const char *dst)
while (waitpid(pid, &ret, 0) < 0) {
if (errno != EINTR) {
ret = -1;
if (geteuid() == 0)
if (geteuid() == 0 && no_xattr == false)
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src,
dst);
else
@ -686,29 +687,41 @@ static bool check_hashmap(Hashmap *hm, const char *item) @@ -686,29 +687,41 @@ static bool check_hashmap(Hashmap *hm, const char *item)

static int dracut_mkdir(const char *src) {
_cleanup_free_ char *parent = NULL;
char *path;
struct stat sb;

parent = strdup(src);
if (!parent)
return 1;

parent[dir_len(parent)] = '\0';
path = parent[0] == '/' ? parent+1 : parent;
while (path) {
path = strstr(path, "/");
if (path)
*path = '\0';

if (stat(parent, &sb) == 0) {
if (!S_ISDIR(sb.st_mode)) {
log_error("%s exists but is not a directory!", parent);
if (stat(parent, &sb) == 0) {
if (!S_ISDIR(sb.st_mode)) {
log_error("%s exists but is not a directory!", parent);
return 1;
}
} else if (errno != ENOENT) {
log_error("ERROR: stat '%s': %s", parent, strerror(errno));
return 1;
} else {
if (mkdir(parent, 0755) < 0) {
log_error("ERROR: mkdir '%s': %s", parent, strerror(errno));
return 1;
}
}

return mkdir(src, 0755);
}

if (errno != ENOENT) {
log_error("ERROR: stat '%s': %m", src);
return 1;
if (path) {
*path = '/';
path++;
}
}

return dracut_mkdir(parent);
return 0;
}

static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir, bool resolvedeps, bool hashdst)
@ -1898,6 +1911,7 @@ int main(int argc, char **argv) @@ -1898,6 +1911,7 @@ int main(int argc, char **argv)
int r;
char *i;
char *path = NULL;
char *env_no_xattr = NULL;

r = parse_argv(argc, argv);
if (r <= 0)
@ -1945,6 +1959,10 @@ int main(int argc, char **argv) @@ -1945,6 +1959,10 @@ int main(int argc, char **argv)
ldd = "ldd";
log_debug("LDD=%s", ldd);

env_no_xattr = getenv("DRACUT_NO_XATTR");
if (env_no_xattr != NULL)
no_xattr = true;

pathdirs = strv_split(path, ":");

umask(0022);

2
lsinitrd.sh

@ -236,6 +236,8 @@ case $bin in @@ -236,6 +236,8 @@ case $bin in
$'\x71\xc7'*|070701)
CAT="cat --"
is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev/null)
# Debian mkinitramfs does not create the file 'early_cpio', so let's check if firmware files exist
[[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2>/dev/null)
if [[ "$is_early" ]]; then
if [[ -n "$unpack" ]]; then
# should use --unpackearly for early CPIO

2
modules.d/00systemd/module-setup.sh

@ -154,6 +154,7 @@ install() { @@ -154,6 +154,7 @@ install() {
mount umount reboot poweroff \
systemd-run systemd-escape \
systemd-cgls systemd-tmpfiles \
systemd-ask-password systemd-tty-ask-password-agent \
/etc/udev/udev.hwdb \
${NULL}

@ -254,4 +255,3 @@ install() { @@ -254,4 +255,3 @@ install() {

systemctl -q --root "$initdir" set-default multi-user.target
}


22
modules.d/35network-legacy/ifup.sh

@ -453,19 +453,15 @@ for p in $(getargs ip=); do @@ -453,19 +453,15 @@ for p in $(getargs ip=); do
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi

case $autoconf in
dhcp|on|any|dhcp6)
;;
*)
if [ $ret -eq 0 ]; then
setup_net $netif
source_hook initqueue/online $netif
if [ -z "$manualup" ]; then
/sbin/netroot $netif
fi
fi
;;
esac
# and finally, finish interface set up if there isn't already a script
# to do so (which is the case in the dhcp path)
if [ ! -e $hookdir/initqueue/setup_net_$netif.sh ]; then
setup_net $netif
source_hook initqueue/online $netif
if [ -z "$manualup" ]; then
/sbin/netroot $netif
fi
fi

if command -v wicked >/dev/null && [ -z "$manualup" ]; then
/sbin/netroot $netif

4
modules.d/35network-legacy/net-genrules.sh

@ -65,9 +65,9 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh @@ -65,9 +65,9 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
bootdev=$(cat /tmp/net.bootdev)
fi

ifup='/sbin/ifup $env{INTERFACE}'
ifup='/sbin/ifup $name'

runcmd="RUN+=\"/sbin/initqueue --name ifup-\$env{INTERFACE} --unique --onetime $ifup\""
runcmd="RUN+=\"/sbin/initqueue --name ifup-\$name --unique --onetime $ifup\""

# We have some specific interfaces to handle
if [ -n "${RAW_IFACES}${IFACES}" ]; then

6
modules.d/40network/net-lib.sh

@ -251,8 +251,10 @@ ibft_to_cmdline() { @@ -251,8 +251,10 @@ ibft_to_cmdline() {
[ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
# Skip invalid interfaces
(( $flags & 1 )) || continue
# Skip interfaces not used for booting
(( $flags & 2 )) || continue
# Skip interfaces not used for booting unless using multipath
if ! getargbool 0 rd.iscsi.mp ; then
(( $flags & 2 )) || continue
fi
[ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
[ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
[ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)

4
modules.d/80cms/cmssetup.sh

@ -164,11 +164,11 @@ processcmsfile() @@ -164,11 +164,11 @@ processcmsfile()
driver=$NETTYPE
fi

printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$name /sbin/cmsifup $name"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
# remove the default net rules
rm -f -- /etc/udev/rules.d/91-default-net.rules
[[ -f /etc/udev/rules.d/90-net.rules ]] \
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$name source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
udevadm control --reload
znet_cio_free
fi

2
modules.d/90stratis/module-setup.sh

@ -26,7 +26,7 @@ install() { @@ -26,7 +26,7 @@ install() {
inst_simple "${moddir}/stratisd-init.service" "${systemdsystemunitdir}/stratisd-init.service"
systemctl -q --root "$initdir" enable stratisd-init.service
else
inst_hook cmdline 25 "$moddir/stratisd-start.sh"
inst_hook pre-mount 25 "$moddir/stratisd-start.sh"
inst_hook cleanup 25 "$moddir/stratisd-stop.sh"
fi
}

8
modules.d/95fcoe/fcoe-genrules.sh

@ -7,10 +7,10 @@ @@ -7,10 +7,10 @@
# Write udev rules
{
if [ -n "$fcoe_mac" ] ; then
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$name /sbin/fcoe-up $name %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$name /sbin/fcoe-up $name %s %s"\n' "$fcoe_mac" "$fcoe_dcb" "$fcoe_mode"
else
printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$env{INTERFACE} /sbin/fcoe-up $env{INTERFACE} %s %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --unique --name fcoe-up-$name /sbin/fcoe-up $name %s %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode"
printf 'ACTION=="add", SUBSYSTEM=="net", NAME=="%s", RUN+="/sbin/initqueue --onetime --timeout --unique --name fcoe-timeout-$name /sbin/fcoe-up $name %s %s"\n' "$fcoe_interface" "$fcoe_dcb" "$fcoe_mode"
fi
} >> /etc/udev/rules.d/92-fcoe.rules

8
modules.d/95nbd/parse-nbdroot.sh

@ -46,10 +46,10 @@ fi @@ -46,10 +46,10 @@ fi
[ "${netroot%%:*}" = "nbd" ] || return


if [ -n "${DRACUT_SYSTEMD}" ] && [ "$root" = "dhcp" ]; then
echo "root=$netroot" > /etc/cmdline.d/root.conf
systemctl --no-block daemon-reload
fi
#if [ -n "${DRACUT_SYSTEMD}" ] && [ "$root" = "dhcp" ]; then
# echo "root=$netroot" > /etc/cmdline.d/root.conf
# systemctl --no-block daemon-reload
#fi

# Check required arguments
netroot_to_var $netroot

2
test/TEST-01-BASIC/create-root.sh

@ -19,7 +19,7 @@ mount /dev/sda2 /root @@ -19,7 +19,7 @@ mount /dev/sda2 /root
cp -a -t /root /source/*
mkdir -p /root/run
umount /root
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
sync
poweroff -f


2
test/TEST-01-BASIC/test-init.sh

@ -100,7 +100,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -100,7 +100,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sdb
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

96
test/TEST-01-BASIC/test.sh

@ -9,14 +9,11 @@ KVERSION=${KVERSION-$(uname -r)} @@ -9,14 +9,11 @@ KVERSION=${KVERSION-$(uname -r)}
test_run() {
dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/result \
-m 512M -smp 2 -nographic \
-net none \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/result \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing || return 1
grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
}

@ -28,10 +25,10 @@ test_setup() { @@ -28,10 +25,10 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-init.sh
(
export initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
@ -39,68 +36,67 @@ test_setup() { @@ -39,68 +36,67 @@ test_setup() {
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.ext3 poweroff cp umount sync
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.ext3 poweroff cp umount sync dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1


(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug watchdog" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug watchdog" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}

test_cleanup() {

2
test/TEST-02-SYSTEMD/create-root.sh

@ -19,6 +19,6 @@ mount /dev/sda2 /root @@ -19,6 +19,6 @@ mount /dev/sda2 /root
cp -a -t /root /source/*
mkdir -p /root/run
umount /root
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
poweroff -f


2
test/TEST-02-SYSTEMD/test-init.sh

@ -102,7 +102,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -102,7 +102,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }

plymouth --quit
exec </dev/console >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

38
test/TEST-02-SYSTEMD/test.sh

@ -8,9 +8,6 @@ KVERSION="${KVERSION-$(uname -r)}" @@ -8,9 +8,6 @@ KVERSION="${KVERSION-$(uname -r)}"
test_run() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
@ -37,8 +34,8 @@ test_setup() { @@ -37,8 +34,8 @@ test_setup() {
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid systemd-analyze
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid systemd-analyze dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -50,14 +47,14 @@ test_setup() { @@ -50,14 +47,14 @@ test_setup() {
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.ext3 poweroff cp umount
inst_multiple sfdisk mkfs.ext3 poweroff cp umount dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
@ -67,17 +64,16 @@ test_setup() { @@ -67,17 +64,16 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
@ -86,20 +82,20 @@ test_setup() { @@ -86,20 +82,20 @@ test_setup() {
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook pre-pivot 000 ./systemd-analyze.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd" \
-o "network kernel-network-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd" \
-o "network kernel-network-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}

test_cleanup() {

7
test/TEST-03-USR-MOUNT/create-root.sh

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
set -x
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
@ -32,9 +33,11 @@ umount /root/usr @@ -32,9 +33,11 @@ umount /root/usr
mount -t btrfs -o subvol=usr /dev/sdb2 /root/usr
cp -a -t /root /source/*
mkdir -p /root/run
btrfs filesystem sync /root/usr
btrfs filesystem sync /root
umount /root/usr
umount /root
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
udevadm settle
sync
poweroff -f


2
test/TEST-03-USR-MOUNT/test-init.sh

@ -109,7 +109,7 @@ ismounted() { @@ -109,7 +109,7 @@ ismounted() {
}

if ismounted /usr; then
echo "dracut-root-block-success" >/dev/sdc
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdc
fi
export TERM=linux
export PS1='initramfs-test:\w\$ '

123
test/TEST-03-USR-MOUNT/test.sh

@ -15,23 +15,15 @@ client_run() { @@ -15,23 +15,15 @@ client_run() {

dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-m 512M -smp 2 -nographic \
-net none \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut $client_opts quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing

if (($? != 0)); then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut $client_opts quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing

if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/result; then
echo "CLIENT TEST END: $test_name [FAILED]"
echo "CLIENT TEST END: $test_name [FAILED]"
return 1
fi
echo "CLIENT TEST END: $test_name [OK]"
@ -55,10 +47,10 @@ test_setup() { @@ -55,10 +47,10 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-init.sh
(
export initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
@ -66,79 +58,80 @@ test_setup() { @@ -66,79 +58,80 @@ test_setup() {
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_simple ./fstab /etc/fstab
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.btrfs btrfs poweroff cp umount sync
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.btrfs btrfs poweroff cp umount sync dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--nohardlink \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--nohardlink \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1

# Invoke KVM and/or QEMU to actually create the target filesystem.

# echo $TESTDIR/overlay
# echo $TESTDIR/initramfs.makeroot
#exit 1
# echo $TESTDIR/overlay
# echo $TESTDIR/initramfs.makeroot
#exit 1
rm -rf -- $TESTDIR/overlay

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1

-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
if ! grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs; then
echo "Could not create root filesystem"
return 1
fi

(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug watchdog" \
-o "network kernel-network-modules" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug watchdog" \
-o "network kernel-network-modules" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

rm -rf -- $TESTDIR/overlay

# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}

test_cleanup() {

6
test/TEST-04-FULL-SYSTEMD/create-root.sh

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
set -x
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
@ -33,9 +34,10 @@ umount /root/usr @@ -33,9 +34,10 @@ umount /root/usr
mount -t btrfs -o subvol=usr /dev/sdb2 /root/usr
cp -a -t /root /source/*
mkdir -p /root/run
btrfs filesystem sync /root/usr
btrfs filesystem sync /root
umount /root/usr
umount /root
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdc
sync
poweroff -f


23
test/TEST-04-FULL-SYSTEMD/test-init.sh

@ -110,19 +110,22 @@ ismounted() { @@ -110,19 +110,22 @@ ismounted() {

systemctl --failed --no-legend --no-pager > /failed

if ismounted /usr && [ ! -s /failed ]; then
echo "dracut-root-block-success" >/dev/sdc
fi

journalctl --full --no-pager -o short-monotonic

if [ -s /failed ]; then
if ! ismounted /usr; then
echo "**************************FAILED**************************"
cat /failed
echo "/usr not mounted!!"
cat /proc/mounts
echo "**************************FAILED**************************"
fi
else
if [ -s /failed ]; then
echo "**************************FAILED**************************"
cat /failed
echo "**************************FAILED**************************"

ls -al /run/systemd/system
else
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdc
echo "All OK"
fi
fi

export TERM=linux
export PS1='initramfs-test:\w\$ '

169
test/TEST-04-FULL-SYSTEMD/test.sh

@ -17,22 +17,14 @@ client_run() { @@ -17,22 +17,14 @@ client_run() {

dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing

if (($? != 0)); then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-append "panic=1 systemd.crash_reboot root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing

if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/result; then
echo "CLIENT TEST END: $test_name [FAILED]"
echo "CLIENT TEST END: $test_name [FAILED]"
return 1
fi
echo "CLIENT TEST END: $test_name [OK]"
@ -56,9 +48,9 @@ test_setup() { @@ -56,9 +48,9 @@ test_setup() {
export kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-init.sh
export initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-init.sh

for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log dev proc sys sysroot root run; do
if [ -L "/$d" ]; then
@ -71,49 +63,47 @@ test_setup() { @@ -71,49 +63,47 @@ test_setup() {
ln -sfn /run "$initdir/var/run"
ln -sfn /run/lock "$initdir/var/lock"

inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less setsid tree systemctl reset
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping dd \
umount strace less setsid tree systemctl reset

for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
done
inst_multiple -o ${_terminfodir}/l/linux
inst_multiple grep
inst_simple ./fstab /etc/fstab
rpm -ql systemd | xargs -r $DRACUT_INSTALL ${initdir:+-D "$initdir"} -o -a -l
inst /lib/systemd/system/systemd-remount-fs.service
inst /lib/systemd/systemd-remount-fs
inst /lib/systemd/system/systemd-journal-flush.service
inst /etc/sysconfig/init
inst /lib/systemd/system/slices.target
inst /lib/systemd/system/system.slice
inst_multiple -o /lib/systemd/system/dracut*
inst /lib/systemd/system/slices.target
inst /lib/systemd/system/system.slice
inst_multiple -o /lib/systemd/system/dracut*

# make a journal directory
mkdir -p $initdir/var/log/journal

# install some basic config files
inst_multiple -o \
/etc/machine-id \
/etc/adjtime \
/etc/sysconfig/init \
/etc/passwd \
/etc/shadow \
/etc/group \
/etc/shells \
/etc/nsswitch.conf \
/etc/pam.conf \
/etc/securetty \
/etc/os-release \
/etc/localtime
/etc/machine-id \
/etc/adjtime \
/etc/passwd \
/etc/shadow \
/etc/group \
/etc/shells \
/etc/nsswitch.conf \
/etc/pam.conf \
/etc/securetty \
/etc/os-release \
/etc/localtime

# we want an empty environment
> $initdir/etc/environment

# setup the testsuite target
mkdir -p $initdir/etc/systemd/system
cat >$initdir/etc/systemd/system/testsuite.target <<EOF
[Unit]
Description=Testsuite target
@ -143,15 +133,15 @@ EOF @@ -143,15 +133,15 @@ EOF
# make the testsuite the default target
ln -fs testsuite.target $initdir/etc/systemd/system/default.target

# mkdir -p $initdir/etc/rc.d
# cat >$initdir/etc/rc.d/rc.local <<EOF
# #!/bin/bash
# exit 0
# EOF
# mkdir -p $initdir/etc/rc.d
# cat >$initdir/etc/rc.d/rc.local <<EOF
# #!/bin/bash
# exit 0
# EOF

# install basic tools needed
inst_multiple sh bash setsid loadkeys setfont \
login sushell sulogin gzip sleep echo mount umount
login sushell sulogin gzip sleep echo mount umount
inst_multiple modprobe

# install libnss_files for login
@ -171,6 +161,8 @@ EOF @@ -171,6 +161,8 @@ EOF
# install dbus socket and service file
inst /usr/lib/systemd/system/dbus.socket
inst /usr/lib/systemd/system/dbus.service
inst /usr/lib/systemd/system/dbus-broker.service
inst /usr/lib/systemd/system/dbus-daemon.service

(
echo "FONT=eurlatgr"
@ -180,11 +172,11 @@ EOF @@ -180,11 +172,11 @@ EOF
# install basic keyboard maps and fonts
for i in \
/usr/lib/kbd/consolefonts/eurlatgr* \
/usr/lib/kbd/keymaps/{legacy/,/}include/* \
/usr/lib/kbd/keymaps/{legacy/,/}i386/include/* \
/usr/lib/kbd/keymaps/{legacy/,/}i386/qwerty/us.*; do
[[ -f $i ]] || continue
inst $i
/usr/lib/kbd/keymaps/{legacy/,/}include/* \
/usr/lib/kbd/keymaps/{legacy/,/}i386/include/* \
/usr/lib/kbd/keymaps/{legacy/,/}i386/qwerty/us.*; do
[[ -f $i ]] || continue
inst $i
done

# some basic terminfo files
@ -217,65 +209,70 @@ EOF @@ -217,65 +209,70 @@ EOF
inst /lib/modules/$kernel/modules.builtin
# generate module dependencies
if [[ -d $initdir/lib/modules/$kernel ]] && \
! depmod -a -b "$initdir" $kernel; then
dfatal "\"depmod -a $kernel\" failed."
exit 1
! depmod -a -b "$initdir" $kernel; then
dfatal "\"depmod -a $kernel\" failed."
exit 1
fi

# disable some services
systemctl --root "$initdir" mask systemd-update-utmp
systemctl --root "$initdir" mask systemd-tmpfiles-setup
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.btrfs btrfs poweroff cp umount sync
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.btrfs btrfs poweroff cp umount sync dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--nohardlink \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "bash udev-rules btrfs base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--nohardlink \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1

# Invoke KVM and/or QEMU to actually create the target filesystem.
rm -rf -- $TESTDIR/overlay

dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1

-drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
-drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
if ! grep -F -m 1 -q dracut-root-block-created $TESTDIR/result; then
echo "Could not create root filesystem"
return 1
fi

(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

[ -e /etc/machine-id ] && EXTRA_MACHINE="/etc/machine-id"
[ -e /etc/machine-info ] && EXTRA_MACHINE+=" /etc/machine-info"

sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd i18n qemu" \
${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
-o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules rngd" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd i18n qemu" \
${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
-o "dash network plymouth lvm mdraid resume crypt caps dm terminfo usrmount kernel-network-modules rngd" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

rm -rf -- $TESTDIR/overlay
}

2
test/TEST-10-RAID/create-root.sh

@ -36,5 +36,5 @@ udevadm settle @@ -36,5 +36,5 @@ udevadm settle
cryptsetup luksClose /dev/mapper/dracut_crypt_test
udevadm settle
eval $(udevadm info --query=env --name=/dev/md0|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } >/dev/sda1
{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } | dd oflag=direct,dsync of=/dev/sda1
poweroff -f

2
test/TEST-10-RAID/test-init.sh

@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
command -v plymouth >/dev/null && plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

92
test/TEST-10-RAID/test.sh

@ -9,12 +9,9 @@ KVERSION=${KVERSION-$(uname -r)} @@ -9,12 +9,9 @@ KVERSION=${KVERSION-$(uname -r)}
test_run() {
DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
}

@ -27,9 +24,9 @@ test_setup() { @@ -27,9 +24,9 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
@ -37,72 +34,71 @@ test_setup() { @@ -37,72 +34,71 @@ test_setup() {
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_multiple -o /lib/systemd/systemd-shutdown
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
inst ./test-init.sh /sbin/init
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_multiple -o /lib/systemd/systemd-shutdown
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/cannotreach rw rootfstype=ext2 console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-append "root=/dev/cannotreach rw rootfstype=ext2 console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
eval $(grep -F -a -m 1 ID_FS_UUID $DISKIMAGE)

(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst ./cryptroot-ask.sh /sbin/cryptroot-ask
inst ./cryptroot-ask.sh /sbin/cryptroot-ask
mkdir -p $initdir/etc
echo "testluks UUID=$ID_FS_UUID /etc/key" > $initdir/etc/crypttab
#echo "luks-$ID_FS_UUID /dev/md0 none" > $initdir/etc/crypttab
echo -n "test" > $initdir/etc/key
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {

2
test/TEST-11-LVM/create-root.sh

@ -27,5 +27,5 @@ umount /sysroot && \ @@ -27,5 +27,5 @@ umount /sysroot && \
sleep 1 && \
lvm lvchange -a n /dev/dracut/root && \
sleep 1 && \
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
poweroff -f

2
test/TEST-11-LVM/test-init.sh

@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

85
test/TEST-11-LVM/test.sh

@ -8,12 +8,9 @@ KVERSION=${KVERSION-$(uname -r)} @@ -8,12 +8,9 @@ KVERSION=${KVERSION-$(uname -r)}

test_run() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
}

@ -24,8 +21,8 @@ test_setup() { @@ -24,8 +21,8 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
@ -35,61 +32,61 @@ test_setup() { @@ -35,61 +32,61 @@ test_setup() {
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
sudo ldconfig -r "$initdir"
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {

10
test/TEST-12-RAID-DEG/create-root.sh

@ -10,14 +10,6 @@ rm -f -- /etc/lvm/lvm.conf @@ -10,14 +10,6 @@ rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
udevadm settle
sleep 1
# save a partition at the beginning for future flagging purposes
sfdisk /dev/sda <<EOF
,5M
,10M
,10M
,10M
EOF
udevadm settle
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
@ -45,4 +37,4 @@ mdadm -W /dev/md0 || : @@ -45,4 +37,4 @@ mdadm -W /dev/md0 || :
mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
. /tmp/mduuid
eval $(udevadm info --query=env --name=/dev/md0|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; echo "ID_FS_UUID=$ID_FS_UUID";} > /dev/sda1
{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID; echo "ID_FS_UUID=$ID_FS_UUID";} | dd oflag=direct,dsync of=/dev/sda

2
test/TEST-12-RAID-DEG/hard-off.sh

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#!/bin/sh
sleep 10
sleep 5
getargbool 0 rd.shell || poweroff -f
! getargbool 0 rd.break && getargbool 0 failme && poweroff -f

2
test/TEST-12-RAID-DEG/test-init.sh

@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
command -v plymouth >/dev/null && plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

37
test/TEST-12-RAID-DEG/test.sh

@ -15,27 +15,25 @@ client_run() { @@ -15,27 +15,25 @@ client_run() {
cp --sparse=always --reflink=auto $TESTDIR/disk3.img $TESTDIR/disk3.img.new

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 512M -nographic -smp 2 \
-drive format=raw,index=0,media=disk,file=$TESTDIR/marker.img \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img.new \
-drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img.new \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot $* systemd.log_target=kmsg loglevel=7 root=LABEL=root rw rd.retry=20 rd.info console=ttyS0,115200n81 log_buf_len=2M selinux=0 rd.debug rd.shell=0 $DEBUGFAIL " \
-append "panic=1 systemd.crash_reboot $* systemd.log_target=kmsg root=LABEL=root rw rd.retry=10 rd.info console=ttyS0,115200n81 log_buf_len=2M selinux=0 rd.shell=0 $DEBUGFAIL " \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/marker.img; then
echo "CLIENT TEST END: $@ [FAIL]"
return 1;
fi
rm -f -- $TESTDIR/marker.img
dd if=/dev/null of=$TESTDIR/marker.img bs=1M seek=40

sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2
echo "CLIENT TEST END: $@ [OK]"
return 0
}

test_run() {
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)
echo "MD_UUID=$MD_UUID"
read LUKS_UUID < $TESTDIR/luksuuid
read MD_UUID < $TESTDIR/mduuid

client_run failme && return 1
client_run rd.auto || return 1
@ -57,8 +55,8 @@ test_run() { @@ -57,8 +55,8 @@ test_run() {

test_setup() {
# Create the blank file to use as a root filesystem
rm -f -- $TESTDIR/root.ext2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=40
rm -f -- $TESTDIR/marker.img
dd if=/dev/null of=$TESTDIR/marker.img bs=1M seek=40
dd if=/dev/null of=$TESTDIR/disk1.img bs=1M seek=35
dd if=/dev/null of=$TESTDIR/disk2.img bs=1M seek=35
dd if=/dev/null of=$TESTDIR/disk3.img bs=1M seek=35
@ -77,7 +75,7 @@ test_setup() { @@ -77,7 +75,7 @@ test_setup() {
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient
mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -89,7 +87,7 @@ test_setup() { @@ -89,7 +87,7 @@ test_setup() {
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
@ -113,23 +111,24 @@ test_setup() { @@ -113,23 +111,24 @@ test_setup() {
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=0,media=disk,file=$TESTDIR/marker.img \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1.img \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1

grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)
eval $(grep -F -a -m 1 ID_FS_UUID $TESTDIR/root.ext2)
grep -F -m 1 -q dracut-root-block-created $TESTDIR/marker.img || return 1
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/marker.img)
eval $(grep -F -a -m 1 ID_FS_UUID $TESTDIR/marker.img)
echo $ID_FS_UUID > $TESTDIR/luksuuid
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/marker.img)
echo "$MD_UUID" > $TESTDIR/mduuid

(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
@ -140,7 +139,7 @@ test_setup() { @@ -140,7 +139,7 @@ test_setup() {
echo -n test > $initdir/etc/key
)

sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

2
test/TEST-13-ENC-RAID-LVM/create-root.sh

@ -51,5 +51,5 @@ cryptsetup luksClose /dev/mapper/dracut_sda4 && \ @@ -51,5 +51,5 @@ cryptsetup luksClose /dev/mapper/dracut_sda4 && \
for i in /dev/sda[234]; do
udevadm info --query=env --name=$i|grep -F 'ID_FS_UUID='
done
} >/dev/sda1
} | dd oflag=direct,dsync of=/dev/sda1
poweroff -f

2
test/TEST-13-ENC-RAID-LVM/test-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sdb
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab

117
test/TEST-13-ENC-RAID-LVM/test.sh

@ -15,13 +15,10 @@ test_run() { @@ -15,13 +15,10 @@ test_run() {

echo "CLIENT TEST START: $LUKSARGS"
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-m 1024M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
echo "CLIENT TEST END: [OK]"

@ -29,13 +26,10 @@ test_run() { @@ -29,13 +26,10 @@ test_run() {

echo "CLIENT TEST START: Any LUKS"
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-m 1024M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
echo "CLIENT TEST END: [OK]"

@ -43,13 +37,10 @@ test_run() { @@ -43,13 +37,10 @@ test_run() {

echo "CLIENT TEST START: Wrong LUKS UUID"
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-m 1024M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1
echo "CLIENT TEST END: [OK]"

@ -64,8 +55,8 @@ test_setup() { @@ -64,8 +55,8 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
@ -75,76 +66,76 @@ test_setup() { @@ -75,76 +66,76 @@ test_setup() {
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount grep
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount grep dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
cryptoUUIDS=$(grep -F --binary-files=text -m 3 ID_FS_UUID $TESTDIR/root.ext2)
for uuid in $cryptoUUIDS; do
eval $uuid
printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID
eval $uuid
printf ' rd.luks.uuid=luks-%s ' $ID_FS_UUID
done > $TESTDIR/luks.txt


(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst ./cryptroot-ask.sh /sbin/cryptroot-ask
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst ./cryptroot-ask.sh /sbin/cryptroot-ask
mkdir -p $initdir/etc
i=2
for uuid in $cryptoUUIDS; do
eval $uuid
printf 'luks-%s /dev/sda%s /etc/key timeout=0\n' $ID_FS_UUID $i
eval $uuid
printf 'luks-%s /dev/sda%s /etc/key timeout=0\n' $ID_FS_UUID $i
((i+=1))
done > $initdir/etc/crypttab
echo -n test > $initdir/etc/key
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {

2
test/TEST-14-IMSM/create-root.sh

@ -73,5 +73,5 @@ udevadm settle @@ -73,5 +73,5 @@ udevadm settle
mdadm --detail --export /dev/md0 |grep -F MD_UUID > /tmp/mduuid
. /tmp/mduuid
echo "MD_UUID=$MD_UUID"
{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID;} > /dev/sda
{ echo "dracut-root-block-created"; echo MD_UUID=$MD_UUID;} | dd oflag=direct,dsync of=/dev/sda
mdadm --wait-clean /dev/md0

2
test/TEST-14-IMSM/test-init.sh

@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda
export TERM=linux
export PS1='initramfs-test:\w\$ '
cat /proc/mdstat

104
test/TEST-14-IMSM/test.sh

@ -10,17 +10,14 @@ KVERSION=${KVERSION-$(uname -r)} @@ -10,17 +10,14 @@ KVERSION=${KVERSION-$(uname -r)}
client_run() {
echo "CLIENT TEST START: $@"
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot $* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
-append "panic=1 systemd.crash_reboot $* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
echo "CLIENT TEST END: $@ [FAIL]"
return 1;
echo "CLIENT TEST END: $@ [FAIL]"
return 1;
fi

sed -i -e 's#dracut-root-block-success#dracut-root-block-xxxxxxx#' $TESTDIR/root.ext2
@ -43,7 +40,7 @@ test_run() { @@ -43,7 +40,7 @@ test_run() {
client_run rd.md.uuid=$MD_UUID rd.md=0 failme && return 1
# the following test hangs on newer md
client_run rd.md.uuid=$MD_UUID rd.dm=0 rd.md.imsm rd.md.conf=0 || return 1
return 0
return 0
}

test_setup() {
@ -59,9 +56,9 @@ test_setup() { @@ -59,9 +56,9 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
@ -69,49 +66,48 @@ test_setup() { @@ -69,49 +66,48 @@ test_setup() {
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst_simple /etc/os-release
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
sudo ldconfig -r "$initdir"
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst_simple /etc/os-release
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount grep
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount grep dd
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid dmraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash lvm mdraid dmraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
-m 512M -nographic -net none \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
eval $(grep -F --binary-files=text -m 1 MD_UUID $TESTDIR/root.ext2)

@ -122,19 +118,19 @@ test_setup() { @@ -122,19 +118,19 @@ test_setup() {

echo $MD_UUID > $TESTDIR/mduuid
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {

2
test/TEST-15-BTRFSRAID/create-root.sh

@ -23,5 +23,5 @@ mkdir -p /sysroot @@ -23,5 +23,5 @@ mkdir -p /sysroot
mount -t btrfs /dev/sda5 /sysroot
cp -a -t /sysroot /source/*
umount /sysroot
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
poweroff -f

2
test/TEST-15-BTRFSRAID/test-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda
sync
export TERM=linux
export PS1='initramfs-test:\w\$ '

90
test/TEST-15-BTRFSRAID/test.sh

@ -10,13 +10,10 @@ test_run() { @@ -10,13 +10,10 @@ test_run() {
MARKER_DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-marker.img
dd if=/dev/zero of=$MARKER_DISKIMAGE bs=512 count=10
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$MARKER_DISKIMAGE \
-drive format=raw,index=1,media=disk,file=$DISKIMAGE \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$MARKER_DISKIMAGE \
-drive format=raw,index=1,media=disk,file=$DISKIMAGE \
-append "panic=1 systemd.crash_reboot root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $MARKER_DISKIMAGE || return 1
}

@ -29,8 +26,8 @@ test_setup() { @@ -29,8 +26,8 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
@ -40,67 +37,66 @@ test_setup() { @@ -40,67 +37,66 @@ test_setup() {
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient sync
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient sync dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst ./test-init.sh /sbin/init
inst_simple /etc/os-release
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst ./test-init.sh /sbin/init
inst_simple /etc/os-release
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.btrfs poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.btrfs poweroff cp umount dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash btrfs udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash btrfs udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1

rm -rf -- $TESTDIR/overlay

# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
-drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1

dd if=$DISKIMAGE bs=512 count=4 skip=2048 | grep -F -m 1 -q dracut-root-block-created || return 1

(
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {

2
test/TEST-16-DMSQUASH/test-init.sh

@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sdb
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

94
test/TEST-16-DMSQUASH/test.sh

@ -14,29 +14,25 @@ test_check() { @@ -14,29 +14,25 @@ test_check() {
fi
done
echo "python-imgcreate not installed"
return 1
return 1
}

test_run() {
"$testdir"/run-qemu \
-boot order=d \
-drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
-drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
-m 512M -smp 2 \
-nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
-initrd "$TESTDIR"/initramfs.testing
-boot order=d \
-drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
-drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
-append "panic=1 systemd.crash_reboot root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
-initrd "$TESTDIR"/initramfs.testing

# mediacheck test with qemu GUI
# "$testdir"/run-qemu \
# -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
# -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
# -m 512M -smp 2 \
# -net none \
# -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
# -initrd "$TESTDIR"/initramfs.testing
# -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
# -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
# -m 512M -smp 2 \
# -net none \
# -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
# -initrd "$TESTDIR"/initramfs.testing

grep -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/root.img || return 1
}
@ -44,30 +40,30 @@ test_run() { @@ -44,30 +40,30 @@ test_run() {
test_setup() {
mkdir -p -- "$TESTDIR"/overlay
(
export initdir="$TESTDIR"/overlay
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir="$TESTDIR"/overlay
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

dd if=/dev/zero of="$TESTDIR"/root.img count=100

sudo $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "debug dmsquash-live qemu" \
-o "rngd" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "debug dmsquash-live qemu" \
-o "rngd" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

mkdir -p -- "$TESTDIR"/root-source
kernel="$KVERSION"
# Create what will eventually be our root filesystem onto an overlay
(
export initdir="$TESTDIR"/root-source
. "$basedir"/dracut-init.sh
(
export initdir="$TESTDIR"/root-source
. "$basedir"/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
@ -75,25 +71,25 @@ test_setup() { @@ -75,25 +71,25 @@ test_setup() {
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
umount strace less dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
done
inst_multiple -o "${_terminfodir}"/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep syslinux isohybrid
for f in /usr/share/syslinux/*; do
inst_simple "$f"
done
[[ -f ${_terminfodir}/l/linux ]] && break
done
inst_multiple -o "${_terminfodir}"/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep syslinux isohybrid
for f in /usr/share/syslinux/*; do
inst_simple "$f"
done
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
inst "$TESTDIR"/initramfs.testing "/boot/initramfs-$KVERSION.img"
inst ./test-init.sh /sbin/init
inst "$TESTDIR"/initramfs.testing "/boot/initramfs-$KVERSION.img"
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id

VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
if ! [[ -e $VMLINUZ ]]; then
if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
@ -101,10 +97,10 @@ test_setup() { @@ -101,10 +97,10 @@ test_setup() {
fi
[[ -e $VMLINUZ ]] || VMLINUZ="/boot/vmlinuz-${KVERSION}"

inst "$VMLINUZ" "/boot/vmlinuz-${KVERSION}"
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a -- /etc/ld.so.conf* "$initdir"/etc
sudo ldconfig -r "$initdir"
inst "$VMLINUZ" "/boot/vmlinuz-${KVERSION}"
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a -- /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
)
python create.py -d -c livecd-fedora-minimal.ks
return 0

2
test/TEST-17-LVM-THIN/create-root.sh

@ -29,5 +29,5 @@ sleep 1 && \ @@ -29,5 +29,5 @@ sleep 1 && \
lvm lvchange -a n /dev/dracut/root && \
sleep 1
dmsetup status |grep out_of_data_space || \
echo "dracut-root-block-created" >/dev/sda1
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sda1
poweroff -f

2
test/TEST-17-LVM-THIN/test-init.sh

@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; } @@ -99,7 +99,7 @@ strstr() { [ "${1##*"$2"*}" != "$1" ]; }
CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline)
plymouth --quit
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
echo "dracut-root-block-success" | dd oflag=direct,dsync of=/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

85
test/TEST-17-LVM-THIN/test.sh

@ -8,12 +8,9 @@ KVERSION=${KVERSION-$(uname -r)} @@ -8,12 +8,9 @@ KVERSION=${KVERSION-$(uname -r)}

test_run() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-m 512M -smp 2 -nographic \
-net none \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
-drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-append "panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
}

@ -24,8 +21,8 @@ test_setup() { @@ -24,8 +21,8 @@ test_setup() {
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p -- dev sys proc etc var/run tmp
@ -35,61 +32,61 @@ test_setup() { @@ -35,61 +32,61 @@ test_setup() {
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
inst_multiple grep
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
sudo ldconfig -r "$initdir"
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount grep dmsetup
inst_hook initqueue 01 ./create-root.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mke2fs poweroff cp umount grep dmsetup dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 512M -smp 2 -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
$testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" -I lvs \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network kernel-network-modules" \
-a "debug" -I lvs \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {

2
test/TEST-20-NFS/client-init.sh

@ -112,7 +112,7 @@ echo "made it to the rootfs! Powering down." @@ -112,7 +112,7 @@ echo "made it to the rootfs! Powering down."

while read dev fs fstype opts rest || [ -n "$dev" ]; do
[ "$fstype" != "nfs" -a "$fstype" != "nfs4" ] && continue
echo "nfs-OK $dev $fstype $opts" > /dev/sda
echo "nfs-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/sda
break
done < /proc/mounts
>/dev/watchdog

46
test/TEST-20-NFS/server-init.sh

@ -14,6 +14,22 @@ wait_for_if_link() { @@ -14,6 +14,22 @@ wait_for_if_link() {
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2>/dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
@ -21,15 +37,33 @@ wait_for_if_link() { @@ -21,15 +37,33 @@ wait_for_if_link() {
return 1
}

wait_for_if_link eth0
wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

linkup() {
wait_for_if_link $1 2>/dev/null\
&& ip link set $1 up 2>/dev/null\
&& wait_for_if_up $1 2>/dev/null
}

wait_for_if_link eth0 ens2

ip addr add 127.0.0.1/8 dev lo
ip link set lo up
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
ip addr add 192.168.50.2/24 dev ens3
ip addr add 192.168.50.3/24 dev ens3
ip link set ens3 up
ip link set dev eth0 name ens2
ip addr add 192.168.50.1/24 dev ens2
ip addr add 192.168.50.2/24 dev ens2
ip addr add 192.168.50.3/24 dev ens2
linkup ens2

echo > /dev/watchdog
modprobe af_packet
echo > /dev/watchdog

121
test/TEST-20-NFS/test.sh

@ -1,10 +1,22 @@ @@ -1,10 +1,22 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on NFS"

if [[ $NM ]]; then
USE_NETWORK="network-manager"
OMIT_NETWORK="network-legacy"
else
USE_NETWORK="network-legacy"
OMIT_NETWORK="network-manager"
fi

TEST_DESCRIPTION="root filesystem on NFS with $USE_NETWORK"

KVERSION=${KVERSION-$(uname -r)}

# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
DEBUGFAIL="loglevel=1"
#DEBUGFAIL="rd.shell rd.break rd.debug loglevel=7 "
#DEBUGFAIL="rd.debug loglevel=7 "
#SERVER_DEBUG="rd.debug loglevel=7"
#SERIAL="tcp:127.0.0.1:9999"

run_server() {
@ -14,24 +26,29 @@ run_server() { @@ -14,24 +26,29 @@ run_server() {
fsck -a $TESTDIR/server.ext3 || return 1
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-m 512M -smp 2 \
-display none \
-net socket,listen=127.0.0.1:12320 \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 systemd.crash_reboot rd.debug loglevel=77 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-append "panic=1 quiet root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1

# Cleanup the terminal if we have one
tty -s && stty sane

echo Sleeping 10 seconds to give the server a head start
sleep 10
if ! [[ $SERIAL ]]; then
while : ; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
sleep 1
done
else
echo Sleeping 10 seconds to give the server a head start
sleep 10
fi
}

client_test() {
@ -45,19 +62,17 @@ client_test() { @@ -45,19 +62,17 @@ client_test() {
echo "CLIENT TEST START: $test_name"

# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1 &>/dev/null; then
echo "Unable to make client sda image" 1>&2
return 1
fi

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
-m 512M -smp 2 -nographic \
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12320 \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet ro console=ttyS0,115200n81 selinux=0" \
-append "rd.net.timeout.dhcp=3 panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=10 quiet ro console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.testing

if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nfs-OK $TESTDIR/client.img; then
@ -113,7 +128,7 @@ test_nfsv3() { @@ -113,7 +128,7 @@ test_nfsv3() {
# NFSv4: last octect starts at 0x80 and works up

client_test "NFSv3 root=dhcp DHCP path only" 52:54:00:12:34:00 \
"root=dhcp" 192.168.50.1 -wsize=4096 || return 1
"root=dhcp" 192.168.50.1 -wsize=4096 || return 1

if [[ "$(systemctl --version)" != *"systemd 230"* ]] 2>/dev/null; then
client_test "NFSv3 Legacy root=/dev/nfs nfsroot=IP:path" 52:54:00:12:34:01 \
@ -127,38 +142,38 @@ test_nfsv3() { @@ -127,38 +142,38 @@ test_nfsv3() {
fi

client_test "NFSv3 root=dhcp DHCP IP:path" 52:54:00:12:34:01 \
"root=dhcp" 192.168.50.2 -wsize=4096 || return 1
"root=dhcp" 192.168.50.2 -wsize=4096 || return 1

client_test "NFSv3 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:02 \
"root=dhcp" 192.168.50.3 -wsize=4096 || return 1
"root=dhcp" 192.168.50.3 -wsize=4096 || return 1

client_test "NFSv3 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:03 \
"root=dhcp" 192.168.50.3 wsize=4096 || return 1
"root=dhcp" 192.168.50.3 wsize=4096 || return 1

client_test "NFSv3 root=nfs:..." 52:54:00:12:34:04 \
"root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
"root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1

client_test "NFSv3 Bridge root=nfs:..." 52:54:00:12:34:04 \
"root=nfs:192.168.50.1:/nfs/client bridge net.ifnames=0" 192.168.50.1 -wsize=4096 || return 1
"root=nfs:192.168.50.1:/nfs/client bridge net.ifnames=0" 192.168.50.1 -wsize=4096 || return 1

client_test "NFSv3 Legacy root=IP:path" 52:54:00:12:34:04 \
"root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
"root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1

# This test must fail: nfsroot= requires root=/dev/nfs
client_test "NFSv3 Invalid root=dhcp nfsroot=/nfs/client" 52:54:00:12:34:04 \
"root=dhcp nfsroot=/nfs/client failme rd.debug" 192.168.50.1 -wsize=4096 && return 1
"root=dhcp nfsroot=/nfs/client failme rd.debug" 192.168.50.1 -wsize=4096 && return 1

client_test "NFSv3 root=dhcp DHCP path,options" \
52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1
52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1

client_test "NFSv3 Bridge Customized root=dhcp DHCP path,options" \
52:54:00:12:34:05 "root=dhcp bridge=foobr0:ens3" 192.168.50.1 wsize=4096 || return 1
52:54:00:12:34:05 "root=dhcp bridge=foobr0:ens2" 192.168.50.1 wsize=4096 || return 1

client_test "NFSv3 root=dhcp DHCP IP:path,options" \
52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1
52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1

client_test "NFSv3 root=dhcp DHCP proto:IP:path,options" \
52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1

return 0
}
@ -169,24 +184,24 @@ test_nfsv4() { @@ -169,24 +184,24 @@ test_nfsv4() {
# switch_root

client_test "NFSv4 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
"root=dhcp" 192.168.50.3 -wsize=4096 || return 1
"root=dhcp" 192.168.50.3 -wsize=4096 || return 1

client_test "NFSv4 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:83 \
"root=dhcp" 192.168.50.3 wsize=4096 || return 1
"root=dhcp" 192.168.50.3 wsize=4096 || return 1

client_test "NFSv4 root=nfs4:..." 52:54:00:12:34:84 \
"root=nfs4:192.168.50.1:/client" 192.168.50.1 \
-wsize=4096 || return 1
"root=nfs4:192.168.50.1:/client" 192.168.50.1 \
-wsize=4096 || return 1

client_test "NFSv4 root=dhcp DHCP proto:IP:path,options" \
52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1

return 0
}

test_run() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi

@ -201,7 +216,7 @@ test_run() { @@ -201,7 +216,7 @@ test_run() {
ret=$?

if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi

@ -213,7 +228,7 @@ test_setup() { @@ -213,7 +228,7 @@ test_setup() {
dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=120
mke2fs -j -F $TESTDIR/server.ext3
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt


export kernel=$KVERSION
@ -236,9 +251,9 @@ test_setup() { @@ -236,9 +251,9 @@ test_setup() {
done

inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod rm
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod rm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -262,7 +277,7 @@ test_setup() { @@ -262,7 +277,7 @@ test_setup() {
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

@ -280,7 +295,7 @@ test_setup() { @@ -280,7 +295,7 @@ test_setup() {
inst /etc/group /etc/group

cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
dracut_kernel_post
)

@ -290,8 +305,8 @@ test_setup() { @@ -290,8 +305,8 @@ test_setup() {
export initdir=$TESTDIR/mnt/nfs/client
. $basedir/dracut-init.sh

inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep setsid ls vi /etc/virc less cat
inst_multiple sh shutdown poweroff stty cat ps ln ip dd \
mount dmesg mkdir cp ping grep setsid ls vi /etc/virc less cat
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -316,21 +331,21 @@ test_setup() { @@ -316,21 +331,21 @@ test_setup() {
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

mkdir -p $TESTDIR/mnt/nfs/nfs3-5
mkdir -p $TESTDIR/mnt/nfs/ip/192.168.50.101
mkdir -p $TESTDIR/mnt/nfs/tftpboot/nfs4-5

sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt

# Make an overlay with needed tools for the test harness
@ -347,23 +362,23 @@ test_setup() { @@ -347,23 +362,23 @@ test_setup() {

# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1

# Make client's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth dash" \
-a "debug watchdog" \
-d "af_packet piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc i6300esb" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
-o "plymouth dash ${OMIT_NETWORK}" \
-a "debug watchdog ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc i6300esb" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
}

test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}

12
test/TEST-21-NFS-NM/Makefile

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
.PHONY: all setup clean run

BASETEST=../TEST-20-NFS

all:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) all
setup:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) setup
clean:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) clean
run:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) run

2
test/TEST-30-ISCSI/client-init.sh

@ -104,7 +104,7 @@ stty sane @@ -104,7 +104,7 @@ stty sane
echo "made it to the rootfs! Powering down."
while read dev fs fstype opts rest || [ -n "$dev" ]; do
[ "$fstype" != "ext3" ] && continue
echo "iscsi-OK $dev $fstype $opts" > /dev/sda
echo "iscsi-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/sda
break
done < /proc/mounts
#sh -i

2
test/TEST-30-ISCSI/create-root.sh

@ -21,5 +21,5 @@ mount /dev/dracut/root /sysroot && \ @@ -21,5 +21,5 @@ mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \
umount /sysroot && \
lvm lvchange -a n /dev/dracut/root && \
echo "dracut-root-block-created" >/dev/sdb
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdb
poweroff -f

24
test/TEST-30-ISCSI/server-init.sh

@ -3,7 +3,7 @@ exec </dev/console >/dev/console 2>&1 @@ -3,7 +3,7 @@ exec </dev/console >/dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
export PS1='nfstest-server:\w\$ '
export PS1='server:\w\$ '
stty sane
echo "made it to the rootfs!"
echo server > /proc/sys/kernel/hostname
@ -13,24 +13,28 @@ wait_for_if_link() { @@ -13,24 +13,28 @@ wait_for_if_link() {
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2>/dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

wait_for_if_link eth0
wait_for_if_link eth1
wait_for_if_link eth0 ens2
wait_for_if_link eth1 ens3

ip addr add 127.0.0.1/8 dev lo
ip link set lo up
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
ip link set dev eth0 name ens2
ip addr add 192.168.50.1/24 dev ens2
ip link set ens2 up
ip link set dev eth1 name ens3
ip addr add 192.168.51.1/24 dev ens3
ip link set ens3 up
ip link set dev eth1 name ens4
ip addr add 192.168.51.1/24 dev ens4
ip link set ens4 up
>/var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
@ -48,8 +52,8 @@ tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101 @@ -48,8 +52,8 @@ tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101


# Wait forever for the VM to die
echo "Serving iSCSI"
while :; do
echo "Serving iSCSI"
[ -n "$(jobs -rp)" ] && echo > /dev/watchdog
sleep 10
done

115
test/TEST-30-ISCSI/test.sh

@ -1,5 +1,14 @@ @@ -1,5 +1,14 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem over iSCSI"

if [[ $NM ]]; then
USE_NETWORK="network-manager"
OMIT_NETWORK="network-legacy"
else
USE_NETWORK="network-legacy"
OMIT_NETWORK="network-manager"
fi

TEST_DESCRIPTION="root filesystem over iSCSI with $USE_NETWORK"

KVERSION=${KVERSION-$(uname -r)}

@ -18,24 +27,30 @@ run_server() { @@ -18,24 +27,30 @@ run_server() {
-drive format=raw,index=1,media=disk,file=$TESTDIR/root.ext3 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-m 512M -smp 2 \
-display none \
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net nic,macaddr=52:54:00:12:34:57,model=e1000 \
-net socket,listen=127.0.0.1:12330 \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-append "panic=1 quiet root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1

# Cleanup the terminal if we have one
tty -s && stty sane

echo Sleeping 20 seconds to give the server a head start
sleep 20
if ! [[ $SERIAL ]]; then
echo "Waiting for the server to startup"
while : ; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
sleep 1
done
else
echo Sleeping 10 seconds to give the server a head start
sleep 10
fi
}

run_client() {
@ -46,17 +61,15 @@ run_client() { @@ -46,17 +61,15 @@ run_client() {

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
-m 512M -smp 2 -nographic \
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net nic,macaddr=52:54:00:12:34:01,model=e1000 \
-net socket,connect=127.0.0.1:12330 \
-no-reboot \
-acpitable file=ibft.table \
-append "panic=1 systemd.crash_reboot rw rd.auto rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 rd.shell=0 $DEBUGFAIL $*" \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q iscsi-OK $TESTDIR/client.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi

echo "CLIENT TEST END: $test_name [OK]"
@ -67,13 +80,13 @@ do_test_run() { @@ -67,13 +80,13 @@ do_test_run() {
initiator=$(iscsi-iname)

run_client "root=dhcp" \
"root=/dev/root netroot=dhcp ip=ens3:dhcp" \
"root=/dev/root netroot=dhcp ip=ens2:dhcp" \
"rd.iscsi.initiator=$initiator" \
|| return 1

run_client "netroot=iscsi target0"\
"root=LABEL=singleroot netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0" \
"ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens3:off" \
"ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens2:off" \
"rd.iscsi.initiator=$initiator" \
|| return 1

@ -103,7 +116,7 @@ test_run() { @@ -103,7 +116,7 @@ test_run() {
do_test_run
ret=$?
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
return $ret
@ -122,6 +135,7 @@ test_setup() { @@ -122,6 +135,7 @@ test_setup() {

kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
rm -rf -- $TESTDIR/overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
@ -135,7 +149,7 @@ test_setup() { @@ -135,7 +149,7 @@ test_setup() {
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep setsid
mount dmesg mkdir cp ping grep setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -143,14 +157,14 @@ test_setup() { @@ -143,14 +157,14 @@ test_setup() {
inst_simple /etc/os-release
inst ./client-init.sh /sbin/init
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.ext3 poweroff cp umount setsid
inst_multiple sfdisk mkfs.ext3 poweroff cp umount setsid dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
@ -160,10 +174,10 @@ test_setup() { @@ -160,10 +174,10 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay


@ -178,33 +192,19 @@ test_setup() { @@ -178,33 +192,19 @@ test_setup() {
-drive format=raw,index=1,media=disk,file=$TESTDIR/client.img \
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-smp 2 -m 512M -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm -- $TESTDIR/client.img
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "dash plymouth dmraid nfs" \
-a "debug" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

# Make server root
dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=60
mkfs.ext3 -j -F $TESTDIR/server.ext3
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt

kernel=$KVERSION
rm -rf -- $TESTDIR/overlay
(
export initdir=$TESTDIR/mnt
. $basedir/dracut-init.sh
@ -214,9 +214,9 @@ test_setup() { @@ -214,9 +214,9 @@ test_setup() {
)
inst /etc/passwd /etc/passwd
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping \
modprobe tcpdump setsid \
/etc/services sleep mount chmod
dmesg mkdir cp ping \
modprobe tcpdump setsid \
/etc/services sleep mount chmod
inst_multiple tgtd tgtadm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
@ -234,25 +234,44 @@ test_setup() { @@ -234,25 +234,44 @@ test_setup() {
inst /etc/group /etc/group

cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
dracut_kernel_post
)

sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt

# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1
rm -rf -- $TESTDIR/overlay

# Make client dracut image
rm -rf -- $TESTDIR/overlay
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf -- $TESTDIR/overlay

}

test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}

12
test/TEST-31-ISCSI-NM/Makefile

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
.PHONY: all setup clean run

BASETEST=../TEST-30-ISCSI

all:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) all
setup:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) setup
clean:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) clean
run:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) run

0
test/TEST-31-ISCSI-MULTI/99-idesymlinks.rules → test/TEST-35-ISCSI-MULTI/99-idesymlinks.rules

0
test/TEST-31-ISCSI-MULTI/Makefile → test/TEST-35-ISCSI-MULTI/Makefile

2
test/TEST-31-ISCSI-MULTI/client-init.sh → test/TEST-35-ISCSI-MULTI/client-init.sh

@ -104,7 +104,7 @@ stty sane @@ -104,7 +104,7 @@ stty sane
echo "made it to the rootfs! Powering down."
while read dev fs fstype opts rest || [ -n "$dev" ]; do
[ "$fstype" != "ext3" ] && continue
echo "iscsi-OK $dev $fstype $opts" > /dev/sda
echo "iscsi-OK $dev $fstype $opts" | dd oflag=direct,dsync of=/dev/sda
break
done < /proc/mounts
#sh -i

2
test/TEST-31-ISCSI-MULTI/create-root.sh → test/TEST-35-ISCSI-MULTI/create-root.sh

@ -21,5 +21,5 @@ mount /dev/dracut/root /sysroot && \ @@ -21,5 +21,5 @@ mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \
umount /sysroot && \
lvm lvchange -a n /dev/dracut/root && \
echo "dracut-root-block-created" >/dev/sdb
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/sdb
poweroff -f

0
test/TEST-31-ISCSI-MULTI/dhcpd.conf → test/TEST-35-ISCSI-MULTI/dhcpd.conf

0
test/TEST-31-ISCSI-MULTI/finished-false.sh → test/TEST-35-ISCSI-MULTI/finished-false.sh

0
test/TEST-31-ISCSI-MULTI/hard-off.sh → test/TEST-35-ISCSI-MULTI/hard-off.sh

0
test/TEST-31-ISCSI-MULTI/hosts → test/TEST-35-ISCSI-MULTI/hosts

52
test/TEST-31-ISCSI-MULTI/server-init.sh → test/TEST-35-ISCSI-MULTI/server-init.sh

@ -3,7 +3,7 @@ exec </dev/console >/dev/console 2>&1 @@ -3,7 +3,7 @@ exec </dev/console >/dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export TERM=linux
export PS1='nfstest-server:\w\$ '
export PS1='server:\w\$ '
stty sane
echo "made it to the rootfs!"
echo server > /proc/sys/kernel/hostname
@ -13,6 +13,22 @@ wait_for_if_link() { @@ -13,6 +13,22 @@ wait_for_if_link() {
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2>/dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
@ -20,17 +36,35 @@ wait_for_if_link() { @@ -20,17 +36,35 @@ wait_for_if_link() {
return 1
}

wait_for_if_link eth0
wait_for_if_link eth1
wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

linkup() {
wait_for_if_link $1 2>/dev/null\
&& ip link set $1 up 2>/dev/null\
&& wait_for_if_up $1 2>/dev/null
}

wait_for_if_link eth0 ens2
wait_for_if_link eth1 ens3

ip addr add 127.0.0.1/8 dev lo
ip link set lo up
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
ip link set ens3 up
ip link set dev eth1 name ens4
ip addr add 192.168.51.1/24 dev ens4
ip link set ens4 up
ip link set dev eth0 name ens2
ip addr add 192.168.50.1/24 dev ens2
linkup ens2
ip link set dev eth1 name ens3
ip addr add 192.168.51.1/24 dev ens3
linkup ens3

>/var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &

125
test/TEST-31-ISCSI-MULTI/test.sh → test/TEST-35-ISCSI-MULTI/test.sh

@ -1,5 +1,14 @@ @@ -1,5 +1,14 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem over multiple iSCSI"

if [[ $NM ]]; then
USE_NETWORK="network-manager"
OMIT_NETWORK="network-legacy"
else
USE_NETWORK="network-legacy"
OMIT_NETWORK="network-manager"
fi

TEST_DESCRIPTION="root filesystem over multiple iSCSI with $USE_NETWORK"

KVERSION=${KVERSION-$(uname -r)}

@ -18,24 +27,30 @@ run_server() { @@ -18,24 +27,30 @@ run_server() {
-drive format=raw,index=1,media=disk,file=$TESTDIR/root.ext3 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-m 512M -smp 2 \
-display none \
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net nic,macaddr=52:54:00:12:34:57,model=e1000 \
-net socket,listen=127.0.0.1:12331 \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1

# Cleanup the terminal if we have one
tty -s && stty sane

echo Sleeping 20 seconds to give the server a head start
sleep 20
if ! [[ $SERIAL ]]; then
while : ; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
tail "$TESTDIR"/server.log
sleep 1
done
else
echo Sleeping 10 seconds to give the server a head start
sleep 10
fi
}

run_client() {
@ -46,16 +61,14 @@ run_client() { @@ -46,16 +61,14 @@ run_client() {

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
-m 512M -smp 2 -nographic \
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net nic,macaddr=52:54:00:12:34:01,model=e1000 \
-net socket,connect=127.0.0.1:12331 \
-no-reboot \
-append "panic=1 systemd.crash_reboot rw rd.auto rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 rd.shell=0 $DEBUGFAIL $*" \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q iscsi-OK $TESTDIR/client.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi

echo "CLIENT TEST END: $test_name [OK]"
@ -66,8 +79,8 @@ do_test_run() { @@ -66,8 +79,8 @@ do_test_run() {
initiator=$(iscsi-iname)
run_client "netroot=iscsi target1 target2" \
"root=LABEL=sysroot" \
"ip=192.168.50.101:::255.255.255.0::ens3:off" \
"ip=192.168.51.101:::255.255.255.0::ens4:off" \
"ip=192.168.50.101:::255.255.255.0::ens2:off" \
"ip=192.168.51.101:::255.255.255.0::ens3:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.initiator=$initiator" \
@ -75,8 +88,8 @@ do_test_run() { @@ -75,8 +88,8 @@ do_test_run() {

run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0" \
"root=LABEL=sysroot" \
"ip=192.168.50.101:::255.255.255.0::ens3:off" \
"ip=192.168.51.101:::255.255.255.0::ens4:off" \
"ip=192.168.50.101:::255.255.255.0::ens2:off" \
"ip=192.168.51.101:::255.255.255.0::ens3:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.firmware" \
@ -86,8 +99,8 @@ do_test_run() { @@ -86,8 +99,8 @@ do_test_run() {

run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0" \
"root=LABEL=sysroot" \
"ip=192.168.50.101:::255.255.255.0::ens3:off" \
"ip=192.168.51.101:::255.255.255.0::ens4:off" \
"ip=192.168.50.101:::255.255.255.0::ens2:off" \
"ip=192.168.51.101:::255.255.255.0::ens3:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.firmware" \
@ -97,8 +110,8 @@ do_test_run() { @@ -97,8 +110,8 @@ do_test_run() {

run_client "netroot=iscsi target1 target2 rd.iscsi.waitnet=0 rd.iscsi.testroute=0 default GW" \
"root=LABEL=sysroot" \
"ip=192.168.50.101::192.168.50.1:255.255.255.0::ens3:off" \
"ip=192.168.51.101::192.168.51.1:255.255.255.0::ens4:off" \
"ip=192.168.50.101::192.168.50.1:255.255.255.0::ens2:off" \
"ip=192.168.51.101::192.168.51.1:255.255.255.0::ens3:off" \
"netroot=iscsi:192.168.51.1::::iqn.2009-06.dracut:target1" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
"rd.iscsi.firmware" \
@ -118,7 +131,7 @@ test_run() { @@ -118,7 +131,7 @@ test_run() {
do_test_run
ret=$?
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
return $ret
@ -137,6 +150,7 @@ test_setup() { @@ -137,6 +150,7 @@ test_setup() {

kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
rm -rf -- $TESTDIR/overlay
(
export initdir=$TESTDIR/overlay/source
. $basedir/dracut-init.sh
@ -150,7 +164,7 @@ test_setup() { @@ -150,7 +164,7 @@ test_setup() {
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep setsid
mount dmesg mkdir cp ping grep setsid dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -158,14 +172,14 @@ test_setup() { @@ -158,14 +172,14 @@ test_setup() {
inst_simple /etc/os-release
inst ./client-init.sh /sbin/init
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple sfdisk mkfs.ext3 poweroff cp umount setsid
inst_multiple sfdisk mkfs.ext3 poweroff cp umount setsid dd
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
@ -175,10 +189,10 @@ test_setup() { @@ -175,10 +189,10 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay


@ -193,33 +207,19 @@ test_setup() { @@ -193,33 +207,19 @@ test_setup() {
-drive format=raw,index=1,media=disk,file=$TESTDIR/client.img \
-drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
-drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-smp 2 -m 512M -nographic -net none \
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm -- $TESTDIR/client.img
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "dash plymouth dmraid nfs" \
-a "debug" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

# Make server root
dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=60
mkfs.ext3 -j -F $TESTDIR/server.ext3
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt

kernel=$KVERSION
rm -rf -- $TESTDIR/overlay
(
export initdir=$TESTDIR/mnt
. $basedir/dracut-init.sh
@ -229,9 +229,9 @@ test_setup() { @@ -229,9 +229,9 @@ test_setup() {
)
inst /etc/passwd /etc/passwd
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping \
modprobe tcpdump setsid \
/etc/services sleep mount chmod
dmesg mkdir cp ping \
modprobe tcpdump setsid \
/etc/services sleep mount chmod
inst_multiple tgtd tgtadm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
@ -249,25 +249,44 @@ test_setup() { @@ -249,25 +249,44 @@ test_setup() {
inst /etc/group /etc/group

cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
dracut_kernel_post
)

sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt

# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1


# Make client dracut image
rm -rf -- $TESTDIR/overlay
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

rm -rf -- $TESTDIR/overlay
}

test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}

12
test/TEST-36-ISCSI-MULTI-NM/Makefile

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
.PHONY: all setup clean run

BASETEST=../TEST-35-ISCSI-MULTI

all:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) all
setup:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) setup
clean:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) clean
run:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) run

2
test/TEST-40-NBD/client-init.sh

@ -5,7 +5,7 @@ exec >/dev/console 2>&1 @@ -5,7 +5,7 @@ exec >/dev/console 2>&1
while read dev fs fstype opts rest || [ -n "$dev" ]; do
[ "$dev" = "rootfs" ] && continue
[ "$fs" != "/" ] && continue
echo "nbd-OK $fstype $opts" >/dev/sda
echo "nbd-OK $fstype $opts" | dd oflag=direct,dsync of=/dev/sda
echo "nbd-OK $fstype $opts"
break
done < /proc/mounts

2
test/TEST-40-NBD/create-root.sh

@ -26,5 +26,5 @@ cryptsetup luksClose /dev/mapper/dracut_crypt_test @@ -26,5 +26,5 @@ cryptsetup luksClose /dev/mapper/dracut_crypt_test
udevadm settle
sleep 1
eval $(udevadm info --query=env --name=/dev/sdb|while read line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo $line; done;)
{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } >/dev/sda
{ echo "dracut-root-block-created"; echo "ID_FS_UUID=$ID_FS_UUID"; } | dd oflag=direct,dsync of=/dev/sda
poweroff -f

38
test/TEST-40-NBD/server-init.sh

@ -13,6 +13,22 @@ wait_for_if_link() { @@ -13,6 +13,22 @@ wait_for_if_link() {
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2>/dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
@ -20,13 +36,31 @@ wait_for_if_link() { @@ -20,13 +36,31 @@ wait_for_if_link() {
return 1
}

wait_for_if_link eth0
wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}

linkup() {
wait_for_if_link $1 2>/dev/null\
&& ip link set $1 up 2>/dev/null\
&& wait_for_if_up $1 2>/dev/null
}

wait_for_if_link eth0 ens3

ip addr add 127.0.0.1/8 dev lo
ip link set lo up
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
ip link set ens3 up
linkup ens3

modprobe af_packet
nbd-server
>/var/lib/dhcpd/dhcpd.leases

167
test/TEST-40-NBD/test.sh

@ -9,8 +9,20 @@ KVERSION=${KVERSION-$(uname -r)} @@ -9,8 +9,20 @@ KVERSION=${KVERSION-$(uname -r)}
#SERIAL="tcp:127.0.0.1:9999"

test_check() {
echo "nbd is constantly broken. skipping"
# NBD is still too flaky and hangs hard sometimes
return 1

if ! type -p nbd-server 2>/dev/null; then
echo "Test needs nbd-server... Skipping"
return 1
fi

if ! modinfo -k $KVERSION nbd &>/dev/null; then
echo "Kernel module nbd does not exist"
return 1
fi

return 0
}

run_server() {
@ -21,22 +33,27 @@ run_server() { @@ -21,22 +33,27 @@ run_server() {
-drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext2 \
-drive format=raw,index=1,media=disk,file=$TESTDIR/nbd.ext2 \
-drive format=raw,index=2,media=disk,file=$TESTDIR/encrypted.ext2 \
-m 512M -smp 2 \
-display none \
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net socket,listen=127.0.0.1:12340 \
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-no-reboot \
-append "panic=1 systemd.crash_reboot root=/dev/sda rootfstype=ext2 rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.server -pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1

# Cleanup the terminal if we have one
tty -s && stty sane

echo Sleeping 10 seconds to give the server a head start
sleep 10
if ! [[ $SERIAL ]]; then
echo "Waiting for the server to startup"
while : ; do
grep Serving "$TESTDIR"/server.log && break
sleep 1
done
else
echo Sleeping 10 seconds to give the server a head start
sleep 10
fi
}

client_test() {
@ -60,11 +77,8 @@ client_test() { @@ -60,11 +77,8 @@ client_test() {

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \
-m 512M -smp 2 \
-nographic \
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12340 \
-no-reboot \
-append "panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81 selinux=0 " \
-initrd $TESTDIR/initramfs.testing

@ -99,7 +113,6 @@ client_test() { @@ -99,7 +113,6 @@ client_test() {
}

test_run() {
modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; exit 1; }
if ! run_server; then
echo "Failed to start server" 1>&2
return 1
@ -129,62 +142,66 @@ client_run() { @@ -129,62 +142,66 @@ client_run() {
"root=nbd:192.168.50.1:raw:ext2:errors=panic bridge rd.luks=0" \
ext2 errors=panic || return 1

#
# FIXME! These fail, but probably shouldn't
#

# There doesn't seem to be a good way to validate the NBD options, so
# just check that we don't screw up the other options

client_test "NBD root=nbd:IP:port:::NBD opts" 52:54:00:12:34:00 \
"root=nbd:192.168.50.1:raw:::bs=2048 rd.luks=0" || return 1

client_test "NBD root=nbd:IP:port:fstype::NBD opts" 52:54:00:12:34:00 \
"root=nbd:192.168.50.1:raw:ext2::bs=2048 rd.luks=0" ext2 || return 1

client_test "NBD root=nbd:IP:port:fstype:fsopts:NBD opts" \
52:54:00:12:34:00 \
"root=nbd:192.168.50.1:raw:ext2:errors=panic:bs=2048 rd.luks=0" \
ext2 errors=panic || return 1
#
# client_test "NBD root=nbd:IP:port:::NBD opts" 52:54:00:12:34:00 \
# "root=nbd:192.168.50.1:raw:::bs=2048 rd.luks=0" || return 1
#
# client_test "NBD root=nbd:IP:port:fstype::NBD opts" 52:54:00:12:34:00 \
# "root=nbd:192.168.50.1:raw:ext2::bs=2048 rd.luks=0" ext2 || return 1
#
# client_test "NBD root=nbd:IP:port:fstype:fsopts:NBD opts" \
# 52:54:00:12:34:00 \
# "root=nbd:192.168.50.1:raw:ext2:errors=panic:bs=2048 rd.luks=0" \
# ext2 errors=panic || return 1

# DHCP root-path parsing

client_test "NBD root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
"root=dhcp rd.luks=0" || return 1
# client_test "NBD root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
# "root=dhcp rd.luks=0" || return 1

client_test "NBD Bridge root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
"root=dhcp bridge rd.luks=0" || return 1
# client_test "NBD Bridge root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
# "root=dhcp bridge rd.luks=0" || return 1

client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype" \
52:54:00:12:34:02 "root=dhcp rd.luks=0" ext2 || return 1
# client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype" \
# 52:54:00:12:34:02 "root=dhcp rd.luks=0" ext2 || return 1

client_test "NBD root=dhcp DHCP root-path nbd:srv:port::fsopts" \
52:54:00:12:34:03 "root=dhcp rd.luks=0" ext3 errors=panic || return 1
# client_test "NBD root=dhcp DHCP root-path nbd:srv:port::fsopts" \
# 52:54:00:12:34:03 "root=dhcp rd.luks=0" ext3 errors=panic || return 1

client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
52:54:00:12:34:04 "root=dhcp rd.luks=0" ext2 errors=panic || return 1
# client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
# 52:54:00:12:34:04 "root=dhcp rd.luks=0" ext2 errors=panic || return 1

# netroot handling

client_test "NBD netroot=nbd:IP:port" 52:54:00:12:34:00 \
"netroot=nbd:192.168.50.1:raw rd.luks=0" || return 1

client_test "NBD netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
52:54:00:12:34:04 "netroot=dhcp rd.luks=0" ext2 errors=panic || return 1
# client_test "NBD netroot=nbd:IP:port" 52:54:00:12:34:00 \
# "netroot=nbd:192.168.50.1:raw rd.luks=0" || return 1
#
# client_test "NBD netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
# 52:54:00:12:34:04 "netroot=dhcp rd.luks=0" ext2 errors=panic || return 1

# Encrypted root handling via LVM/LUKS over NBD

. $TESTDIR/luks.uuid

client_test "NBD root=LABEL=dracut netroot=nbd:IP:port" \
52:54:00:12:34:00 \
"root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=nbd:192.168.50.1:encrypted" || return 1
# . $TESTDIR/luks.uuid
#
# client_test "NBD root=LABEL=dracut netroot=nbd:IP:port" \
# 52:54:00:12:34:00 \
# "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=nbd:192.168.50.1:encrypted" || return 1

# XXX This should be ext2,errors=panic but that doesn't currently
# XXX work when you have a real root= line in addition to netroot=
# XXX How we should work here needs clarification
client_test "NBD root=LABEL=dracut netroot=dhcp (w/ fstype and opts)" \
52:54:00:12:34:05 \
"root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=dhcp" || return 1
# client_test "NBD root=LABEL=dracut netroot=dhcp (w/ fstype and opts)" \
# 52:54:00:12:34:05 \
# "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=dhcp" || return 1

if [[ -s server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi

@ -192,7 +209,7 @@ client_run() { @@ -192,7 +209,7 @@ client_run() {

make_encrypted_root() {
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/encrypted.ext2 bs=1M seek=40
dd if=/dev/null of=$TESTDIR/encrypted.ext2 bs=1M seek=80
dd if=/dev/null of=$TESTDIR/flag.img bs=1M seek=1

kernel=$KVERSION
@ -203,14 +220,14 @@ make_encrypted_root() { @@ -203,14 +220,14 @@ make_encrypted_root() {
mkdir -p "$initdir"
(
cd "$initdir"
mkdir -p dev sys proc etc var tmp run root usr/bin usr/lib usr/lib64 usr/sbin
mkdir -p dev sys proc etc var tmp run root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
ln -s ../run var/run
ln -s ../run var/run
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping
mount dmesg mkdir cp ping dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -219,7 +236,7 @@ make_encrypted_root() { @@ -219,7 +236,7 @@ make_encrypted_root() {
inst_simple /etc/os-release
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

# second, install the files needed to make the root filesystem
@ -228,13 +245,13 @@ make_encrypted_root() { @@ -228,13 +245,13 @@ make_encrypted_root() {
. $basedir/dracut-init.sh
(
cd "$initdir"
mkdir -p dev sys proc etc tmp var run root usr/bin usr/lib usr/lib64 usr/sbin
mkdir -p dev sys proc etc tmp var run root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
ln -s ../run var/run
ln -s ../run var/run
)
inst_multiple mke2fs poweroff cp umount tune2fs
inst_multiple mke2fs poweroff cp umount tune2fs dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_hook initqueue 01 ./create-root.sh
@ -256,8 +273,6 @@ make_encrypted_root() { @@ -256,8 +273,6 @@ make_encrypted_root() {
$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \
-drive format=raw,index=1,media=disk,file=$TESTDIR/encrypted.ext2 \
-m 512M -smp 2\
-nographic -net none \
-append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1
@ -265,10 +280,13 @@ make_encrypted_root() { @@ -265,10 +280,13 @@ make_encrypted_root() {
}

make_client_root() {
dd if=/dev/null of=$TESTDIR/nbd.ext2 bs=1M seek=60
dd if=/dev/null of=$TESTDIR/nbd.ext2 bs=1M seek=120
mke2fs -F -j $TESTDIR/nbd.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt
if ! mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt; then
echo "Cannot mount loop"
return 1
fi

kernel=$KVERSION
(
@ -277,14 +295,14 @@ make_client_root() { @@ -277,14 +295,14 @@ make_client_root() {
mkdir -p "$initdir"
(
cd "$initdir"
mkdir -p dev sys proc etc var tmp run root usr/bin usr/lib usr/lib64 usr/sbin
mkdir -p dev sys proc etc var tmp run root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
ln -s ../run var/run
ln -s ../run var/run
)
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping
dmesg mkdir cp ping dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
@ -299,18 +317,18 @@ make_client_root() { @@ -299,18 +317,18 @@ make_client_root() {
inst $i
done
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
}

make_server_root() {
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=120
mke2fs -F $TESTDIR/server.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt

kernel=$KVERSION
(
@ -320,16 +338,18 @@ make_server_root() { @@ -320,16 +338,18 @@ make_server_root() {
(
cd "$initdir";
mkdir -p run dev sys proc etc var var/lib/dhcpd tmp etc/nbd-server
ln -s ../run var/run
ln -s ../run var/run
)
cat > "$initdir/etc/nbd-server/config" <<EOF
[generic]
[raw]
exportname = /dev/sdb
port = 2000
bs = 4096
[encrypted]
exportname = /dev/sdc
port = 2001
bs = 4096
EOF
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping grep \
@ -354,17 +374,14 @@ EOF @@ -354,17 +374,14 @@ EOF
done

cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
}

test_setup() {

modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; exit 1; }

make_encrypted_root || return 1
make_client_root || return 1
make_server_root || return 1
@ -373,7 +390,7 @@ test_setup() { @@ -373,7 +390,7 @@ test_setup() {
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-init.sh
inst_multiple poweroff shutdown
inst_multiple poweroff shutdown dd
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
inst ./cryptroot-ask.sh /sbin/cryptroot-ask
@ -388,13 +405,13 @@ test_setup() { @@ -388,13 +405,13 @@ test_setup() {
echo -n test > $initdir/etc/key
)

sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules rootfs-block fs-lib base debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1

sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth" \
-a "debug watchdog" \
-d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000 i6300esb ib700wdt" \
@ -404,7 +421,7 @@ test_setup() { @@ -404,7 +421,7 @@ test_setup() {

kill_server() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}

12
test/TEST-41-NBD-NM/Makefile

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
.PHONY: all setup clean run

BASETEST=../TEST-20-NFS

all:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) all
setup:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) setup
clean:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) clean
run:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) run

2
test/TEST-50-MULTINIC/client-init.sh

@ -124,7 +124,7 @@ done @@ -124,7 +124,7 @@ done
{
echo "OK"
echo "$IFACES"
} > /dev/sda
} | dd oflag=direct,dsync of=/dev/sda

getargbool 0 rd.shell && sh -i
poweroff -f

11
test/TEST-50-MULTINIC/server-init.sh

@ -13,7 +13,11 @@ wait_for_if_link() { @@ -13,7 +13,11 @@ wait_for_if_link() {
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2>/dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
cnt=$(($cnt+1))
done
@ -49,7 +53,7 @@ linkup() { @@ -49,7 +53,7 @@ linkup() {
&& wait_for_if_up $1 2>/dev/null
}

wait_for_if_link eth0
wait_for_if_link eth0 ens3

>/dev/watchdog
ip addr add 127.0.0.1/8 dev lo
@ -57,6 +61,7 @@ linkup lo @@ -57,6 +61,7 @@ linkup lo
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
linkup ens3

>/dev/watchdog
modprobe af_packet
> /dev/watchdog
@ -79,7 +84,7 @@ rpc.nfsd @@ -79,7 +84,7 @@ rpc.nfsd
>/dev/watchdog
rpc.mountd
>/dev/watchdog
rpc.idmapd
rpc.idmapd -S
>/dev/watchdog
exportfs -r
>/dev/watchdog

74
test/TEST-50-MULTINIC/test.sh

@ -1,5 +1,14 @@ @@ -1,5 +1,14 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on NFS with multiple nics"

if [[ $NM ]]; then
USE_NETWORK="network-manager"
OMIT_NETWORK="network-legacy"
else
USE_NETWORK="network-legacy"
OMIT_NETWORK="network-manager"
fi

TEST_DESCRIPTION="root filesystem on NFS with multiple nics with $USE_NETWORK"

KVERSION=${KVERSION-$(uname -r)}

@ -15,25 +24,30 @@ run_server() { @@ -15,25 +24,30 @@ run_server() {

$testdir/run-qemu \
-drive format=raw,index=0,media=disk,file="$TESTDIR"/server.ext3 \
-m 512M -smp 2 \
-display none \
-net socket,listen=127.0.0.1:12350 \
-net nic,macaddr=52:54:01:12:34:56,model=e1000 \
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 systemd.crash_reboot loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-initrd "$TESTDIR"/initramfs.server \
-pidfile "$TESTDIR"/server.pid -daemonize || return 1

sudo chmod 644 -- "$TESTDIR"/server.pid || return 1
chmod 644 -- "$TESTDIR"/server.pid || return 1

# Cleanup the terminal if we have one
tty -s && stty sane

echo Sleeping 10 seconds to give the server a head start
sleep 10
if ! [[ $SERIAL ]]; then
while : ; do
grep Serving "$TESTDIR"/server.log && break
echo "Waiting for the server to startup"
sleep 1
done
else
echo Sleeping 10 seconds to give the server a head start
sleep 10
fi
}

client_test() {
@ -52,7 +66,7 @@ client_test() { @@ -52,7 +66,7 @@ client_test() {
return 1
fi

$testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img -m 512M -smp 2 -nographic \
$testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img \
-net socket,connect=127.0.0.1:12350 \
-net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \
-net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
@ -62,8 +76,7 @@ client_test() { @@ -62,8 +76,7 @@ client_test() {
-device e1000,netdev=n1,mac=52:54:00:12:34:98 \
-device e1000,netdev=n2,mac=52:54:00:12:34:99 \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
-append "quiet rd.net.timeout.dhcp=3 panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console" \
-initrd "$TESTDIR"/initramfs.testing

{ read OK; read IFACES; } < "$TESTDIR"/client.img
@ -114,45 +127,46 @@ test_client() { @@ -114,45 +127,46 @@ test_client() {
client_test "MULTINIC root=nfs BOOTIF=" \
00 01 02 \
"root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
"ens3" || return 1
"ens2" || return 1

client_test "MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
00 01 02 \
"root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
"ens3 ens4" || return 1
"root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens3:dhcp" \
"ens2 ens3" || return 1

# PXE Style BOOTIF= with dhcp root-path
client_test "MULTINIC root=dhcp BOOTIF=" \
00 01 02 \
"root=dhcp BOOTIF=52-54-00-12-34-02" \
"ens5" || return 1
"ens4" || return 1

# Multinic case, where only one nic works
client_test "MULTINIC root=nfs ip=dhcp" \
FF 00 FE \
"root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
"ens4" || return 1
"ens3" || return 1

# Require two interfaces
client_test "MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
client_test "MULTINIC root=nfs ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
00 01 02 \
"root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
"ens4 ens5" || return 1
"root=nfs:192.168.50.1:/nfs/client ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
"ens3 ens4" || return 1

# Require three interfaces with dhcp root-path
client_test "MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
client_test "MULTINIC root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
00 01 02 \
"root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
"ens3 ens4 ens5" || return 1
"root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
"ens2 ens3 ens4" || return 1

client_test "MULTINIC bonding" \
00 01 02 \
"root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
"root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens2,ens3,ens4:mode=balance-rr" \
"bond0" || return 1

# bridge, where only one interface is actually connected
client_test "MULTINIC bridging" \
00 01 02 \
"root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens6,ens7" \
"root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens2,ens6,ens7" \
"bridge0" || return 1
return 0
}
@ -162,7 +176,7 @@ test_setup() { @@ -162,7 +176,7 @@ test_setup() {
dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=120
mke2fs -j -F -- "$TESTDIR"/server.ext3
mkdir -- "$TESTDIR"/mnt
sudo mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
kernel=$KVERSION
(
export initdir="$TESTDIR"/mnt
@ -243,7 +257,7 @@ test_setup() { @@ -243,7 +257,7 @@ test_setup() {
done
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep ls
mount dmesg mkdir cp ping grep ls dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
done
@ -267,10 +281,10 @@ test_setup() { @@ -267,10 +281,10 @@ test_setup() {
inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a -- /etc/ld.so.conf* "$initdir"/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)

sudo umount "$TESTDIR"/mnt
umount "$TESTDIR"/mnt
rm -fr -- "$TESTDIR"/mnt

# Make an overlay with needed tools for the test harness
@ -295,8 +309,8 @@ test_setup() { @@ -295,8 +309,8 @@ test_setup() {
# Make client's dracut image
$basedir/dracut.sh \
-l -i "$TESTDIR"/overlay / \
-o "plymouth" \
-a "debug" \
-o "plymouth ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
@ -304,7 +318,7 @@ test_setup() { @@ -304,7 +318,7 @@ test_setup() {

kill_server() {
if [[ -s "$TESTDIR"/server.pid ]]; then
sudo kill -TERM -- $(cat "$TESTDIR"/server.pid)
kill -TERM -- $(cat "$TESTDIR"/server.pid)
rm -f -- "$TESTDIR"/server.pid
fi
}

12
test/TEST-51-MULTINIC-NM/Makefile

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
.PHONY: all setup clean run

BASETEST=../TEST-50-MULTINIC

all:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) all
setup:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) setup
clean:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) clean
run:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) run

0
test/TEST-60-IFCFG/99-default.link → test/TEST-60-BONDBRIDGEVLANIFCFG/99-default.link

0
test/TEST-60-IFCFG/99-idesymlinks.rules → test/TEST-60-BONDBRIDGEVLANIFCFG/99-idesymlinks.rules

0
test/TEST-60-IFCFG/Makefile → test/TEST-60-BONDBRIDGEVLANIFCFG/Makefile

6
test/TEST-60-IFCFG/client-init.sh → test/TEST-60-BONDBRIDGEVLANIFCFG/client-init.sh

@ -12,11 +12,11 @@ echo "made it to the rootfs! Powering down." @@ -12,11 +12,11 @@ echo "made it to the rootfs! Powering down."
echo OK
ip -o -4 address show scope global | while read n if rest; do echo $if;done | sort
for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
echo $i
grep -v 'UUID=' $i
echo $i
grep -v 'UUID=' $i
done
echo EOF
) > /dev/sda
) | dd oflag=direct,dsync of=/dev/sda

strstr "$CMDLINE" "rd.shell" && sh -i
poweroff -f

0
test/TEST-60-IFCFG/dhcpd.conf → test/TEST-60-BONDBRIDGEVLANIFCFG/dhcpd.conf

0
test/TEST-60-IFCFG/exports → test/TEST-60-BONDBRIDGEVLANIFCFG/exports

0
test/TEST-60-IFCFG/finished-false.sh → test/TEST-60-BONDBRIDGEVLANIFCFG/finished-false.sh

0
test/TEST-60-IFCFG/hard-off.sh → test/TEST-60-BONDBRIDGEVLANIFCFG/hard-off.sh

0
test/TEST-60-IFCFG/hosts → test/TEST-60-BONDBRIDGEVLANIFCFG/hosts

62
test/TEST-60-IFCFG/server-init.sh → test/TEST-60-BONDBRIDGEVLANIFCFG/server-init.sh

@ -13,7 +13,11 @@ wait_for_if_link() { @@ -13,7 +13,11 @@ wait_for_if_link() {
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
[ -n "$li" ] && return 0
if [[ $2 ]]; then
li=$(ip -o link show dev $2 2>/dev/null)
[ -n "$li" ] && return 0
fi
sleep 0.1
cnt=$(($cnt+1))
done
@ -49,38 +53,38 @@ linkup() { @@ -49,38 +53,38 @@ linkup() {
&& wait_for_if_up $1 2>/dev/null
}

wait_for_if_link eth0
wait_for_if_link eth1
wait_for_if_link eth2
wait_for_if_link eth3
wait_for_if_link eth0 ens2
wait_for_if_link eth1 ens3
wait_for_if_link eth2 ens4
wait_for_if_link eth3 ens5

modprobe --all -b -q 8021q ipvlan macvlan
>/dev/watchdog
ip addr add 127.0.0.1/8 dev lo
linkup lo
ip link set dev eth0 name ens3
ip addr add 192.168.50.1/24 dev ens3
ip link set dev eth0 name ens2
ip addr add 192.168.50.1/24 dev ens2
linkup ens2
>/dev/watchdog
ip link set dev eth1 name ens3
ip link add dev ens3.1 link ens3 type vlan id 1
ip link add dev ens3.2 link ens3 type vlan id 2
ip link add dev ens3.3 link ens3 type vlan id 3
ip link add dev ens3.4 link ens3 type vlan id 4
ip addr add 192.168.54.1/24 dev ens3.1
ip addr add 192.168.55.1/24 dev ens3.2
ip addr add 192.168.56.1/24 dev ens3.3
ip addr add 192.168.57.1/24 dev ens3.4
linkup ens3
>/dev/watchdog
ip link set dev eth1 name ens4
ip link add dev ens4.1 link ens4 type vlan id 1
ip link add dev ens4.2 link ens4 type vlan id 2
ip link add dev ens4.3 link ens4 type vlan id 3
ip link add dev ens4.4 link ens4 type vlan id 4
ip addr add 192.168.54.1/24 dev ens4.1
ip addr add 192.168.55.1/24 dev ens4.2
ip addr add 192.168.56.1/24 dev ens4.3
ip addr add 192.168.57.1/24 dev ens4.4
ip link set dev ens3.1 up
ip link set dev ens3.2 up
ip link set dev ens3.3 up
ip link set dev ens3.4 up
ip link set dev eth2 name ens4
ip addr add 192.168.51.1/24 dev ens4
linkup ens4
ip link set dev ens4.1 up
ip link set dev ens4.2 up
ip link set dev ens4.3 up
ip link set dev ens4.4 up
ip link set dev eth2 name ens5
ip addr add 192.168.51.1/24 dev ens5
ip link set dev eth3 name ens5
linkup ens5
ip link set dev eth3 name ens6
linkup ens6
>/dev/watchdog
modprobe af_packet
> /dev/watchdog
@ -103,7 +107,7 @@ rpc.nfsd @@ -103,7 +107,7 @@ rpc.nfsd
>/dev/watchdog
rpc.mountd
>/dev/watchdog
rpc.idmapd
rpc.idmapd -S
>/dev/watchdog
exportfs -r
>/dev/watchdog
@ -111,12 +115,12 @@ exportfs -r @@ -111,12 +115,12 @@ exportfs -r
>/dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
>/dev/watchdog
dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens2 ens4
#echo -n 'V' > /dev/watchdog
#sh -i
#tcpdump -i ens3
#tcpdump -i ens2
# Wait forever for the VM to die
echo "Serving NFS mounts"
echo "Serving"
while :; do
sleep 10
>/dev/watchdog

156
test/TEST-60-IFCFG/test.sh → test/TEST-60-BONDBRIDGEVLANIFCFG/test.sh

@ -1,7 +1,18 @@ @@ -1,7 +1,18 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan"


if [[ $NM ]]; then
USE_NETWORK="network-manager"
OMIT_NETWORK="network-legacy"
else
USE_NETWORK="network-legacy"
OMIT_NETWORK="network-manager"
fi

TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan with $USE_NETWORK"

KVERSION=${KVERSION-$(uname -r)}

# Uncomment this to debug failures
@ -17,8 +28,6 @@ run_server() { @@ -17,8 +28,6 @@ run_server() {

$testdir/run-qemu \
-hda "$TESTDIR"/server.ext3 \
-m 512M -smp 2 \
-display none \
-netdev socket,id=n0,listen=127.0.0.1:12370 \
-netdev socket,id=n1,listen=127.0.0.1:12371 \
-netdev socket,id=n2,listen=127.0.0.1:12372 \
@ -30,7 +39,6 @@ run_server() { @@ -30,7 +39,6 @@ run_server() {
${SERIAL:+-serial "$SERIAL"} \
${SERIAL:--serial file:"$TESTDIR"/server.log} \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 rd.debug" \
-initrd "$TESTDIR"/initramfs.server \
-pidfile "$TESTDIR"/server.pid -daemonize || return 1
@ -39,8 +47,16 @@ run_server() { @@ -39,8 +47,16 @@ run_server() {
# Cleanup the terminal if we have one
tty -s && stty sane

echo Sleeping 10 seconds to give the server a head start
sleep 10
if ! [[ $SERIAL ]]; then
echo "Waiting for the server to startup"
while : ; do
grep Serving "$TESTDIR"/server.log && break
sleep 1
done
else
echo Sleeping 10 seconds to give the server a head start
sleep 10
fi
}

client_test() {
@ -67,39 +83,20 @@ client_test() { @@ -67,39 +83,20 @@ client_test() {
nic3=" -netdev hubport,id=n3,hubid=3"
fi

if $testdir/run-qemu --help | grep -qF -m1 'netdev hubport,id=str,hubid=n[,netdev=nd]' && echo OK; then
$testdir/run-qemu \
-hda "$TESTDIR"/client.img -m 512M -smp 2 -nographic \
-netdev socket,connect=127.0.0.1:12370,id=s1 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,mac=52:54:00:12:34:01,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device e1000,mac=52:54:00:12:34:02,netdev=h3 \
$nic1 -device e1000,mac=52:54:00:12:34:03,netdev=n1 \
-netdev socket,connect=127.0.0.1:12372,id=n2 -device e1000,mac=52:54:00:12:34:04,netdev=n2 \
$nic3 -device e1000,mac=52:54:00:12:34:05,netdev=n3 \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 $cmdline rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
-initrd "$TESTDIR"/initramfs.testing
else
$testdir/run-qemu \
-hda "$TESTDIR"/client.img -m 512M -smp 2 -nographic \
-net socket,vlan=0,connect=127.0.0.1:12370 \
${do_vlan13:+-net socket,vlan=1,connect=127.0.0.1:12371} \
-net socket,vlan=2,connect=127.0.0.1:12372 \
${do_vlan13:+-net socket,vlan=3,connect=127.0.0.1:12373} \
-net nic,vlan=0,macaddr=52:54:00:12:34:01,model=e1000 \
-net nic,vlan=0,macaddr=52:54:00:12:34:02,model=e1000 \
-net nic,vlan=1,macaddr=52:54:00:12:34:03,model=e1000 \
-net nic,vlan=2,macaddr=52:54:00:12:34:04,model=e1000 \
-net nic,vlan=3,macaddr=52:54:00:12:34:05,model=e1000 \
-watchdog i6300esb -watchdog-action poweroff \
-no-reboot \
-append "panic=1 $cmdline rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
-initrd "$TESTDIR"/initramfs.testing
fi
$testdir/run-qemu \
-hda "$TESTDIR"/client.img \
-netdev socket,connect=127.0.0.1:12370,id=s1 \
-netdev hubport,hubid=1,id=h1,netdev=s1 \
-netdev hubport,hubid=1,id=h2 -device e1000,mac=52:54:00:12:34:01,netdev=h2 \
-netdev hubport,hubid=1,id=h3 -device e1000,mac=52:54:00:12:34:02,netdev=h3 \
$nic1 -device e1000,mac=52:54:00:12:34:03,netdev=n1 \
-netdev socket,connect=127.0.0.1:12372,id=n2 -device e1000,mac=52:54:00:12:34:04,netdev=n2 \
$nic3 -device e1000,mac=52:54:00:12:34:05,netdev=n3 \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 $cmdline systemd.crash_reboot rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
-initrd "$TESTDIR"/initramfs.testing

{
{
read OK
if [[ "$OK" != "OK" ]]; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
@ -135,9 +132,15 @@ test_run() { @@ -135,9 +132,15 @@ test_run() {
}

test_client() {
if [[ $NM ]]; then
EXPECT='ens3 ens5.0004 ens5.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-* EOF '
else
EXPECT='ens3 ens5.0004 ens5.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" DEVICE="ens3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.0004 # Generated by dracut initrd NAME="ens5.0004" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens5.0004" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.3 # Generated by dracut initrd NAME="ens5.3" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens5.3" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens5" EOF '
fi

client_test "Multiple VLAN" \
"yes" \
"
"yes" \
"
vlan=vlan0001:ens5
vlan=vlan2:ens5
vlan=ens5.3:ens5
@ -150,41 +153,52 @@ ip=192.168.57.104::192.168.57.1:24:test:ens5.0004:none @@ -150,41 +153,52 @@ ip=192.168.57.104::192.168.57.1:24:test:ens5.0004:none
rd.neednet=1
root=nfs:192.168.50.1:/nfs/client bootdev=ens3
" \
'ens3 ens5.0004 ens5.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" DEVICE="ens3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.0004 # Generated by dracut initrd NAME="ens5.0004" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens5.0004" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.3 # Generated by dracut initrd NAME="ens5.3" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens5.3" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens5" EOF ' \
|| return 1
"$EXPECT" \
|| return 1

if [[ $NM ]]; then
EXPECT='bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-* EOF '
else
EXPECT='bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond0 # Generated by dracut initrd NAME="bond0" DEVICE="bond0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond0" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond1 # Generated by dracut initrd NAME="bond1" DEVICE="bond1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond1" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens3" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens7" EOF '
fi

client_test "Multiple Bonds" \
"yes" \
"
bond=bond0:ens4,ens5
"yes" \
"
bond=bond0:ens3,ens4
bond=bond1:ens6,ens7
ip=bond0:dhcp
ip=bond1:dhcp
rd.neednet=1
root=nfs:192.168.50.1:/nfs/client bootdev=bond0
" \
'bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond0 # Generated by dracut initrd NAME="bond0" DEVICE="bond0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond0" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond1 # Generated by dracut initrd NAME="bond1" DEVICE="bond1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond1" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens7" EOF ' \
|| return 1
"$EXPECT" \
|| return 1

if [[ $NM ]]; then
EXPECT='br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-* EOF '
else
EXPECT='br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br0 # Generated by dracut initrd NAME="br0" DEVICE="br0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br0" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br1 # Generated by dracut initrd NAME="br1" DEVICE="br1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br1" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens3" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens7" EOF '
fi

client_test "Multiple Bridges" \
"no" \
"
bridge=br0:ens4,ens5
"no" \
"
bridge=br0:ens3,ens4
bridge=br1:ens6,ens7
ip=br0:dhcp
ip=br1:dhcp
rd.neednet=1
root=nfs:192.168.50.1:/nfs/client bootdev=br0
" \
'br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br0 # Generated by dracut initrd NAME="br0" DEVICE="br0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br0" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br1 # Generated by dracut initrd NAME="br1" DEVICE="br1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br1" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens7" EOF ' \
|| return 1

"$EXPECT" \
|| return 1
kill_server
return 0
}

test_setup() {
# Make server root
# Make server root
dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=120
mke2fs -j -F -- "$TESTDIR"/server.ext3
mkdir -- "$TESTDIR"/mnt
@ -213,9 +227,9 @@ test_setup() { @@ -213,9 +227,9 @@ test_setup() {
done

inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f "${_terminfodir}"/l/linux ] && break
done
@ -240,7 +254,7 @@ test_setup() { @@ -240,7 +254,7 @@ test_setup() {
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

@ -260,7 +274,7 @@ test_setup() { @@ -260,7 +274,7 @@ test_setup() {
export initdir="$TESTDIR"/mnt/nfs/client
. "$basedir"/dracut-init.sh
inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep ls sort
mount dmesg mkdir cp ping grep ls sort dd
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
done
@ -282,7 +296,7 @@ test_setup() { @@ -282,7 +296,7 @@ test_setup() {
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

@ -307,20 +321,20 @@ test_setup() { @@ -307,20 +321,20 @@ test_setup() {

# Make server's dracut image
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
--no-early-microcode \
-m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
-d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
--no-early-microcode \
-m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
-d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

# Make client's dracut image
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
--no-early-microcode \
-o "plymouth" \
-a "debug network-legacy" \
-d "ipvlan macvlan af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
--no-early-microcode \
-o "plymouth ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "ipvlan macvlan af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
}

kill_server() {

12
test/TEST-61-BONDBRIDGEVLANIFCFG-NM/Makefile

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
.PHONY: all setup clean run

BASETEST=../TEST-60-BONDBRIDGEVLANIFCFG

all:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) all
setup:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) setup
clean:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) clean
run:
@$(MAKE) NM=1 -s --no-print-directory -C $(BASETEST) run

6
test/TEST-70-BONDBRIDGETEAMVLAN/99-default.link

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
MACAddressPolicy=keep

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save