#!/bin/bash # Perform a smoke test on a target's cross compiler by building "hello world" # and attempting to run it under QEMU application emulation. source sources/include.sh && load_target $1 || exit 1 # Build statically linked hello world, if necessary if test ! -e "$WORK/hello" { "$(ARCH)-gcc" -Os -static "$(SOURCES)/toys/hello.c" -o "$WORK"/hello if test $Status -ne 0 { echo "Compiler doesn't seem to work" > !2 dienow } } # Attempt to run statically linked hello world global RESULT := $[env PATH=$OLDPATH qemu-"$QEMU_TEST" "$WORK/hello] if test $RESULT == "Hello world!" { echo "Cross toolchain seems to work." exit 0 } else { echo "Can't run hello world" > !2 exit 1 } (CommandList children: [ (AndOr children: [ (C {(source)} {(sources/include.sh)}) (AndOr children: [(C {(load_target)} {(DQ ($ VSub_Number "$1"))}) (C {(exit)} {(1)})] op_id: Op_DPipe ) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(KW_Bang "!")} {(-e)} {(DQ ($ VSub_Name "$WORK") (/hello))} {(Lit_Other "]")} ) ] action: [ (C {(DQ (${ VSub_Name ARCH) (-gcc))} {(-Os)} {(-static)} {(DQ (${ VSub_Name SOURCES) (/toys/hello.c))} {(-o)} {(DQ ($ VSub_Name "$WORK")) (/hello)} ) (If arms: [ (if_arm cond: [(C {(Lit_Other "[")} {($ VSub_QMark "$?")} {(-ne)} {(0)} {(Lit_Other "]")})] action: [ (SimpleCommand words: [{(echo)} {(DQ ("Compiler doesn't seem to work"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[101])] ) (C {(dienow)}) ] spids: [-1 92] ) ] spids: [-1 108] ) ] spids: [-1 49] ) ] spids: [-1 110] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RESULT) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {(qemu-) (DQ ($ VSub_Name "$QEMU_TEST"))} {(DQ ($ VSub_Name "$WORK") (/hello))} ] more_env: [ (env_pair name: PATH val: {(DQ ($ VSub_Name "$OLDPATH"))} spids: [120] ) ] ) ] ) left_token: spids: [119 134] ) ) } spids: [117] ) ] spids: [117] ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$RESULT"))} {(Lit_Other "=") (Lit_Other "=")} {(DQ ("Hello world!"))} {(Lit_Other "]")} ) ] action: [(C {(echo)} {(DQ ("Cross toolchain seems to work."))}) (C {(exit)} {(0)})] spids: [-1 154] ) ] else_action: [ (SimpleCommand words: [{(echo)} {(DQ ("Can't run hello world"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[177])] ) (C {(exit)} {(1)}) ] spids: [168 185] ) ] )