. "$BST_LIB" require usleep usleep/present # /bin/usleep must be the standalone meta-oe utility (update-alternatives priority # 80), not the busybox applet at 50 — the busybox applet takes a bare count and # knows none of the popt long options asserted below. check_out usleep/version "usleep version 1.2" usleep --version # popt option dispatch: --oot is a standalone-only flag, and POPT_AUTOHELP builds # --help from the option table plus poptSetOtherOptionHelp's "[microseconds]". check_out usleep/oot "oot says hey" usleep --oot check_out usleep/help "[microseconds]" usleep --help # no argument -> count defaults to 1 us; a plain count sleeps and exits 0. check usleep/default usleep check usleep/count usleep 200000 # two arguments is the documented usage error (rc 2), which also proves poptGetArg # walked the residual argv rather than the option table. check_rc usleep/two-args 2 usleep 1 2 # The clock must actually advance: 3 x 999999 us ~ 3.0 s, so a second-granularity # sample reads >= 2 even with truncation at both ends. Each count stays under 1e6, # where usleep(3) is defined. This is what separates a real sleep from a no-op. t0=$(date +%s) usleep 999999; usleep 999999; usleep 999999 t1=$(date +%s) el=$((t1 - t0)) if [ "$el" -ge 2 ]; then bst_ok usleep/elapsed else bst_notok usleep/elapsed "3 x 999999us advanced the clock only ${el}s"; fi