X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=blobdiff_plain;f=test%2Fcommand_ut.c;h=aaa1ee25d0f6a371deb478e41506900fda047510;hp=4f420569a2d045b13e09aba5a9d0545390c67ac2;hb=23869bf80b68af9ef1802b9e556f4fd0e9e57fe5;hpb=eebd1b58d05aa3719aa23be3e4a5c1424b26ff11 diff --git a/test/command_ut.c b/test/command_ut.c index 4f420569a2..aaa1ee25d0 100644 --- a/test/command_ut.c +++ b/test/command_ut.c @@ -7,6 +7,9 @@ #define DEBUG #include +#ifdef CONFIG_SANDBOX +#include +#endif static const char test_cmd[] = "setenv list 1\n setenv list ${list}2; " "setenv list ${list}3\0" @@ -138,12 +141,30 @@ static int do_ut_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) HUSH_TEST(or_1_0_inv_inv, "! ! aaa = aaa -o ! ! bbb != bbb", y); HUSH_TEST(or_1_1_inv_inv, "! ! aaa = aaa -o ! ! bbb = bbb", y); + setenv("ut_var_nonexistent", NULL); + setenv("ut_var_exists", "1"); + HUSH_TEST(z_varexp_quoted, "-z \"$ut_var_nonexistent\"", y); + HUSH_TEST(z_varexp_quoted, "-z \"$ut_var_exists\"", n); + setenv("ut_var_exists", NULL); + + run_command("setenv ut_var_space \" \"", 0); + assert(!strcmp(getenv("ut_var_space"), " ")); + run_command("setenv ut_var_test $ut_var_space", 0); + assert(!getenv("ut_var_test")); + run_command("setenv ut_var_test \"$ut_var_space\"", 0); + assert(!strcmp(getenv("ut_var_test"), " ")); + run_command("setenv ut_var_test \" 1${ut_var_space}${ut_var_space} 2 \"", 0); + assert(!strcmp(getenv("ut_var_test"), " 1 2 ")); + setenv("ut_var_space", NULL); + setenv("ut_var_test", NULL); + #ifdef CONFIG_SANDBOX - /* - * File existence - * This assume U-Boot sandbox is run from the U-Boot build directory - */ - HUSH_TEST(e, "-e host - u-boot", y); + /* File existence */ + HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", n); + run_command("sb save host - creating_this_file_breaks_uboot_unit_test 0 1", 0); + HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", y); + /* Perhaps this could be replaced by an "rm" shell command one day */ + assert(!os_unlink("creating_this_file_breaks_uboot_unit_test")); HUSH_TEST(e, "-e host - creating_this_file_breaks_uboot_unit_test", n); #endif #endif