[Toybox] Multiple OS support in tests

Rob Landley rob at landley.net
Fri Jan 18 11:14:01 PST 2019


On 1/18/19 11:59 AM, Ed Maste wrote:
> I applied a few hacks to run tests on FreeBSD - changes like (hostname.test):
> 
> -HOST="$(cat /proc/sys/kernel/hostname)"
> +HOST=$(sysctl -n kern.hostname)
> 
> Of course this isn't an acceptable upstream change; what's the most
> desirable way to handle these? One approach would be something like:

Hmmm...

  $ toybox sysctl -n kern.hostname
  sysctl: unknown key 'kern.hostname'
  $ sysctl -n kern.hostname
  sysctl: cannot stat /proc/sys/kern/hostname: No such file or directory
  $ toybox sysctl -n kernel.hostname
  halfbrick

You know... I think ubuntu's error message is clearer. :)

Does the longer name work on BSD, or just the short one?

> case $(uname -s) in
> FreeBSD)
>     HOST=$(sysctl -n kern.hostname)
>     ;;
> Linux)
>     HOST=$(cat /proc/sys/kernel/hostname)
>     ;;
> esac
> 
> but perhaps this is too verbose in the individual tests?

I could do a tests-portability.sh but let's hold off and collect a few and try
to actually fix them first...

Rob

> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
> 



More information about the Toybox mailing list