Skip to content

Commit

Permalink
aii-ks: fix some more regex tests after new nmc-lib-blockdevices
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird committed Mar 18, 2021
1 parent c051fb1 commit 16d5ba1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 38 deletions.
4 changes: 0 additions & 4 deletions aii-ks/src/test/resources/regexps/pre_blocksize_blockdevices
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Test the blockdevice generation in the pre section with disk with valid size def
^\s{4}fi$
^\s{4}end=\$\(\(begin \+ 100 \* \(1024 \* 1024 / sectsize\) - 1\)\)
^\s{4}parted /dev/sdb -s -- u s mkpart primary \$begin \$end$
^\s{4}wipe_metadata /dev/sdb1$
^\s{4}echo /dev/sdb1 >> /tmp/created_partitions$
^fi$
^valid_disksize_MiB /dev/sdb 3996 400[34]$
Expand Down Expand Up @@ -61,7 +60,6 @@ Test the blockdevice generation in the pre section with disk with valid size def
^\s{4}fi$
^\s{4}end=\$\(\(begin \+ 100 \* \(1024 \* 1024 / sectsize\) - 1\)\)
^\s{4}parted /dev/sdb -s -- u s mkpart primary \$begin \$end$
^\s{4}wipe_metadata /dev/sdb2$
^\s{4}echo /dev/sdb2 >> /tmp/created_partitions$
^fi$
^valid_disksize_MiB /dev/sdb 3996 400[34]$
Expand Down Expand Up @@ -92,7 +90,6 @@ Test the blockdevice generation in the pre section with disk with valid size def
^\s{4}fi$
^\s{4}end=\$\(\(begin \+ 2500 \* \(1024 \* 1024 / sectsize\) - 1\)\)
^\s{4}parted /dev/sdb -s -- u s mkpart extended \$begin \$end$
^\s{4}wipe_metadata /dev/sdb3$
^\s{4}echo /dev/sdb3 >> /tmp/created_partitions$
^fi$
^valid_disksize_MiB /dev/sdb 3996 400[34]$
Expand Down Expand Up @@ -123,7 +120,6 @@ Test the blockdevice generation in the pre section with disk with valid size def
^\s{4}fi$
^\s{4}end=\$\(\(begin \+ 1024 \* \(1024 \* 1024 / sectsize\) - 1\)\)
^\s{4}parted /dev/sdb -s -- u s mkpart logical \$begin \$end$
^\s{4}wipe_metadata /dev/sdb4$
^\s{4}echo /dev/sdb4 >> /tmp/created_partitions$
^fi$
^lvm vgscan --mknodes$
Expand Down
67 changes: 33 additions & 34 deletions aii-ks/src/test/resources/regexps/pre_noblock_functions
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ Test the functions in the pre section
^echo 'Begin of pre section'$
^set -x$
^$
^wipe_metadata \(\) \{$
^\s{4}local path clear SIZE ENDSEEK ENDSEEK_OFFSET$
^\s{4}path="\$1"$
^$
^\s{4}# default to 1$
^\s{4}clearmb="\$\{2:-1\}"$
^$
^\s{4}# wipe at least 4 MiB at begin and end$
^\s{4}ENDSEEK_OFFSET=4$
^\s{4}if \[ "\$clearmb" -gt \$ENDSEEK_OFFSET \]; then$
^\s{8}ENDSEEK_OFFSET=\$clearmb$
^\s{4}fi$
^\s{4}\# try to get the size with fdisk$
^\s{4}SIZE=`disksize_MiB "\$path"`$
^$
^\s{4}\# if empty, assume we failed and try with parted$
^\s{4}if \[ \$SIZE -eq 0 \]; then$
^\s{8}\# the SIZE has not been determined,$
^\s{8}\# set it equal to ENDSEEK_OFFSET, the entire disk gets wiped.$
^\s{8}SIZE=\$ENDSEEK_OFFSET$
^\s{8}echo "\[WARN\] Could not determine the size of device \$path with both fdisk and parted. Wiping whole drive instead"$
^\s{4}fi$
^$
^\s{4}let ENDSEEK=\$SIZE-\$ENDSEEK_OFFSET$
^\s{4}if \[ \$ENDSEEK -lt 0 \]; then$
^\s{8}ENDSEEK=0$
^\s{4}fi$
^\s{4}echo "\[INFO\] wipe path \$path with SIZE \$SIZE and ENDSEEK \$ENDSEEK"$
^\s{4}\# dd with 1 MiB blocksize \(unit used by disksize_MiB and faster then e.g. bs=512\)$
^\s{4}dd if=/dev/zero of="\$path" bs=1048576 count=\$ENDSEEK_OFFSET$
^\s{4}dd if=/dev/zero of="\$path" bs=1048576 seek=\$ENDSEEK$
^\s{4}sync$
^\}$
^$
^disksize_MiB \(\) \{$
^\s{4}local path BYTES MB RET$
Expand Down Expand Up @@ -46,37 +79,3 @@ Test the functions in the pre section
^\s{4}echo "\[\$msg\] Found path \$path size \$SIZE min \$min max \$max"$
^\s{4}return \$RET$
^\}$
^$
^wipe_metadata \(\) \{$
^\s{4}local path clear SIZE ENDSEEK ENDSEEK_OFFSET$
^\s{4}path="\$1"$
^$
^\s{4}# default to 1$
^\s{4}clearmb="\$\{2:-1\}"$
^$
^\s{4}# wipe at least 4 MiB at begin and end$
^\s{4}ENDSEEK_OFFSET=4$
^\s{4}if \[ "\$clearmb" -gt \$ENDSEEK_OFFSET \]; then$
^\s{8}ENDSEEK_OFFSET=\$clearmb$
^\s{4}fi$
^\s{4}\# try to get the size with fdisk$
^\s{4}SIZE=`disksize_MiB "\$path"`$
^$
^\s{4}\# if empty, assume we failed and try with parted$
^\s{4}if \[ \$SIZE -eq 0 \]; then$
^\s{8}\# the SIZE has not been determined,$
^\s{8}\# set it equal to ENDSEEK_OFFSET, the entire disk gets wiped.$
^\s{8}SIZE=\$ENDSEEK_OFFSET$
^\s{8}echo "\[WARN\] Could not determine the size of device \$path with both fdisk and parted. Wiping whole drive instead"$
^\s{4}fi$
^$
^\s{4}let ENDSEEK=\$SIZE-\$ENDSEEK_OFFSET$
^\s{4}if \[ \$ENDSEEK -lt 0 \]; then$
^\s{8}ENDSEEK=0$
^\s{4}fi$
^\s{4}echo "\[INFO\] wipe path \$path with SIZE \$SIZE and ENDSEEK \$ENDSEEK"$
^\s{4}\# dd with 1 MiB blocksize \(unit used by disksize_MiB and faster then e.g. bs=512\)$
^\s{4}dd if=/dev/zero of="\$path" bs=1048576 count=\$ENDSEEK_OFFSET$
^\s{4}dd if=/dev/zero of="\$path" bs=1048576 seek=\$ENDSEEK$
^\s{4}sync$
^\}$

0 comments on commit 16d5ba1

Please sign in to comment.