. "$BST_LIB" require toybox toybox/present # toybox is a busybox-style multi-call binary: bare `toybox` lists the applets it # was built with, and `toybox [args]` dispatches one. check_out toybox/applets "echo" toybox check_out toybox/echo "hello" toybox echo hello check_out toybox/uname "Linux" toybox uname -s # Applet dispatch must be the real applet, not an echo of its name: sort the # lines out of order and require them back in order. sorted=$(printf '%s\n' charlie alpha bravo | toybox sort | tr '\n' ' ') check_eq toybox/sort "alpha bravo charlie " "$sorted" # Packaging constraint (the point of this port): this image's /bin links belong # to busybox and the GNU userland, so toybox installs with no applet symlinks # registered. Anything but /bin/toybox itself resolving to the toybox binary is # a hijacked link and fails the suite. hij= for f in /bin/* /usr/bin/* /sbin/* /usr/sbin/*; do [ -L "$f" ] || continue [ "$f" = /bin/toybox ] && continue case "$(readlink "$f")" in *toybox*) hij="$hij $f" ;; esac done check_eq toybox/no-hijack "" "$hij" # The links busybox and coreutils own must still be theirs. check_out toybox/sh-intact "BusyBox" sh -c 'busybox | head -1'