#!/bin/bash
###############################################################################
# Script : slackwareaarch64-<ver>/source/k/scripts/validate_kmod_loader_scripts
# Purpose: Validate that the modules definied within the Slackware ARM Kernel
#          module loader scripts exist and could be loaded.
# Author : Stuart Winter <mozes@slackware.com>
# Jan-2026
###############################################################################

source /usr/share/slackdev/buildkit.sh

# Each script triggers if the HWM is set to 'PLATWALK', as this is the test
# case.
export HWM=PLATWALK

for platformscr in $PORTSRC/source/k/SlkOS-initrd-overlay/load_kernel_modules.scr/platform/$ARCH/* ; do
   echo "=== Testing Loader: ${platformscr} ==="
   . $platformscr
   for modname in $(compgen -v MOD_); do
      #echo "Module variable: ${modname}"
      for kmod in $( echo ${!modname} ); do
         # We are only interested in what's missing:
         modinfo $kmod > /dev/null 2>&1 || { echo "MISSING: var name: ${modname} Kernel module: ${kmod}" ;}
      done
      unset "${modname}"
   done
done

