test_probe_samples.sh 948 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # Copyright (c) 2023 Collabora Ltd
  5. #
  6. # This script tests whether the rust sample modules can
  7. # be added and removed correctly.
  8. #
  9. DIR="$(dirname "$(readlink -f "$0")")"
  10. KTAP_HELPERS="${DIR}/../kselftest/ktap_helpers.sh"
  11. if [ -e "$KTAP_HELPERS" ]; then
  12. source "$KTAP_HELPERS"
  13. else
  14. echo "$KTAP_HELPERS file not found [SKIP]"
  15. exit 4
  16. fi
  17. rust_sample_modules=("rust_minimal" "rust_print")
  18. ktap_print_header
  19. for sample in "${rust_sample_modules[@]}"; do
  20. if ! /sbin/modprobe -n -q "$sample"; then
  21. ktap_skip_all "module $sample is not found in /lib/modules/$(uname -r)"
  22. exit "$KSFT_SKIP"
  23. fi
  24. done
  25. ktap_set_plan "${#rust_sample_modules[@]}"
  26. for sample in "${rust_sample_modules[@]}"; do
  27. if /sbin/modprobe -q "$sample"; then
  28. /sbin/modprobe -q -r "$sample"
  29. ktap_test_pass "$sample"
  30. else
  31. ktap_test_fail "$sample"
  32. fi
  33. done
  34. ktap_finished