test-build-userland 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/usr/bin/env bash
  2. # https://cirosantilli.com/linux-kernel-module-cheat#cli-script-tests
  3. set -eux
  4. for in_tree in '' --in-tree; do
  5. userland_build_dir="$(./getvar $in_tree userland_build_dir)"
  6. # Toplevel.
  7. ./build-userland $in_tree
  8. [ -f "${userland_build_dir}/c/hello.out" ]
  9. ./build-userland $in_tree --clean
  10. ! [ -f "${userland_build_dir}/c/hello.out" ]
  11. # Toplevel explicit.
  12. ./build-userland $in_tree userland/
  13. [ -f "${userland_build_dir}/c/hello.out" ]
  14. ./build-userland $in_tree --clean
  15. ! [ -f "${userland_build_dir}/c/hello.out" ]
  16. # Toplevel root dir.
  17. ./build-userland $in_tree .
  18. [ -f "${userland_build_dir}/c/hello.out" ]
  19. ./build-userland $in_tree --clean
  20. ! [ -f "${userland_build_dir}/c/hello.out" ]
  21. # Subdirectory.
  22. ./build-userland $in_tree userland/c
  23. [ -f "${userland_build_dir}/c/hello.out" ]
  24. ./build-userland $in_tree --clean userland/c
  25. ! [ -f "${userland_build_dir}/c/hello.out" ]
  26. # One program.
  27. ./build-userland $in_tree userland/c/hello.c
  28. [ -f "${userland_build_dir}/c/hello.out" ]
  29. ./build-userland $in_tree --clean userland/c/hello.c
  30. ! [ -f "${userland_build_dir}/c/hello.out" ]
  31. # Things that don't work: building:
  32. # - non-existent files
  33. # - paths outside of tree
  34. ! ./build-userland $in_tree userland/c/hello
  35. ! ./build-userland $in_tree userland/c/hello.
  36. ! ./build-userland $in_tree "${userland_build_dir}/c/hello.out"
  37. tmpfile="$(mktemp)"
  38. ! ./build-userland $in_tree "$tmpfile"
  39. ! ./build-userland --clean $in_tree "$tmpfile"
  40. rm "$tmpfile"
  41. ! ./build-userland $in_tree ..
  42. ! ./build-userland $in_tree kernel_modules
  43. ! ./build-userland --clean $in_tree userland/does_not_exist
  44. ./build-userland --clean $in_tree
  45. done
  46. ./build-userland-in-tree
  47. [ -f userland/c/hello.out ]
  48. ./build-userland-in-tree --clean
  49. ! [ -f userland/c/hello.out ]
  50. cd userland
  51. ./build
  52. [ -f c/hello.out ]
  53. ./build --clean
  54. ! [ -f c/hello.out ]
  55. ./build c
  56. [ -f c/hello.out ]
  57. ./build --clean c
  58. ! [ -f c/hello.out ]
  59. ./build --clean c/hello.c
  60. ! [ -f c/hello.out ]