#!/bin/bash # Test: profiledef.sh validity # Validates that profiledef.sh exists, has valid bash syntax, and defines # all required archiso profile variables. source "$(dirname "$0")/test_helper.sh" suite "profiledef.sh tests" PROFILEDEF="$PROFILE_DIR/profiledef.sh" assert_file_exists "profiledef.sh exists" "$PROFILEDEF" assert "profiledef.sh has valid bash syntax" \ bash -n "$PROFILEDEF" # profiledef.sh uses associative arrays without explicit `declare -A`, # relying on mkarchiso's caller context. Pre-declare so plain bash can source it. SOURCE_CMD='declare -A file_permissions; source "'"$PROFILEDEF"'"' # Source the file in a subshell and verify required variables are set assert "profiledef.sh defines iso_name" \ bash -c "$SOURCE_CMD; [ -n \"\$iso_name\" ]" assert "profiledef.sh defines iso_version" \ bash -c "$SOURCE_CMD; [ -n \"\$iso_version\" ]" assert "profiledef.sh defines iso_publisher" \ bash -c "$SOURCE_CMD; [ -n \"\$iso_publisher\" ]" assert "profiledef.sh defines iso_application" \ bash -c "$SOURCE_CMD; [ -n \"\$iso_application\" ]" assert "profiledef.sh defines arch" \ bash -c "$SOURCE_CMD; [ -n \"\$arch\" ]" assert "iso_name is 'samios'" \ bash -c "$SOURCE_CMD; [ \"\$iso_name\" = 'samios' ]" assert "arch is 'x86_64'" \ bash -c "$SOURCE_CMD; [ \"\$arch\" = 'x86_64' ]" assert "buildmodes array is non-empty" \ bash -c "$SOURCE_CMD; [ \${#buildmodes[@]} -gt 0 ]" assert "bootmodes array is non-empty" \ bash -c "$SOURCE_CMD; [ \${#bootmodes[@]} -gt 0 ]" assert "file_permissions includes /usr/local/bin/samios" \ bash -c "$SOURCE_CMD; [ -n \"\${file_permissions[/usr/local/bin/samios]}\" ]" assert "file_permissions includes /etc/shadow" \ bash -c "$SOURCE_CMD; [ -n \"\${file_permissions[/etc/shadow]}\" ]" print_summary