sonic-buildimage/installer/tests/test_read_conf.sh

62 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/sh
# This is a standalone test file to test read_conf_file function for
# some types of machine.conf file.
# The read_conf_file function is copy from the install.sh
MACHINE_CONF="sample_machine.conf"
read_conf_file() {
local conf_file=$1
while IFS='=' read -r var value || [ -n "$var" ]
do
# remove newline character
var=$(echo $var | tr -d '\r\n')
value=$(echo $value | tr -d '\r\n')
# remove comment string
var=${var%#*}
value=${value%#*}
# skip blank line
[ -z "$var" ] && continue
# remove double quote in the beginning
tmp_val=${value#\"}
# remove double quote in the end
value=${tmp_val%\"}
eval "$var=\"$value\""
done < "$conf_file"
}
TEST_CONF() {
input_value=$1
exp_value=$2
if [ "$input_value" != "$exp_value" ]; then
echo "[ERR] Expect value($exp_value) is not equal to input value($input_value)"
exit 1
fi
}
# define the expected variable value
exp_onie_machine_rev="0"
exp_onie_arch="x86_64"
exp_onie_build_date="2021-02-03T01:50+0800"
exp_onie_partition_type="gpt"
exp_onie_disco_ntpsrv="192.168.0.1 192.168.0.2"
exp_onie_firmware="auto"
exp_onie_skip_ethmgmt_macs="no"
exp_onie_grub_image_name="grubx64.efi"
# read the sample conf file
read_conf_file $MACHINE_CONF
# check each variable and its expected value
TEST_CONF "$onie_machine_rev" "$exp_onie_machine_rev"
TEST_CONF "$onie_arch" "$exp_onie_arch"
TEST_CONF "$onie_build_date" "$exp_onie_build_date"
TEST_CONF "$onie_partition_type" "$exp_onie_partition_type"
TEST_CONF "$onie_disco_ntpsrv" "$exp_onie_disco_ntpsrv"
TEST_CONF "$onie_firmware" "$exp_onie_firmware"
TEST_CONF "$onie_skip_ethmgmt_macs" "$exp_onie_skip_ethmgmt_macs"
TEST_CONF "$onie_grub_image_name" "$exp_onie_grub_image_name"
echo "PASS!!"
[arm] Refactor installer and build to allow arm builds targeted at grub platforms (#11341) Refactors the SONiC Installer to support greater flexibility in building for a given architecture and bootloader. #### Why I did it Currently the SONiC installer assumes that if a platform is ARM based that it uses the `uboot` bootloader and uses the `grub` bootloader otherwise. This is not a correct assumption to make as ARM is not strictly tied to uboot and x86 is not strictly tied to grub. #### How I did it To implement this I introduce the following changes: * Remove the different arch folders from the `installer/` directory * Merge the generic components of the ARM and x86 installer into `installer/installer.sh` * Refactor x86 + grub specific functions into `installer/default_platform.conf` * Modify installer to call `default_platform.conf` file and also call `platform/[platform]/patform.conf` file as well to override as needed * Update references to the installer in the `build_image.sh` script * Add `TARGET_BOOTLOADER` variable that is by default `uboot` for ARM devices and `grub` for x86 unless overridden in `platform/[platform]/rules.mk` * Update bootloader logic in `build_debian.sh` to be based on `TARGET_BOOTLOADER` instead of `TARGET_ARCH` and to reference the grub package in a generic manner #### How to verify it This has been tested on a ARM test platform as well as on Mellanox amd64 switches as well to ensure there was no impact. #### Description for the changelog [arm] Refactor installer and build to allow arm builds targeted at grub platforms #### Link to config_db schema for YANG module changes N/A
2022-07-12 17:00:57 -05:00
exit 0