diff options
author | Christian Mauderer <Christian.Mauderer@embedded-brains.de> | 2016-07-15 11:39:48 +0200 |
---|---|---|
committer | Christian Mauderer <Christian.Mauderer@embedded-brains.de> | 2016-08-02 10:21:38 +0200 |
commit | 3d9134086847bc755fd9dcc7f6149f8871d6a6ed (patch) | |
tree | e7b1f68cfd9f6448511aedf3eac31b45b24f82ed /testsuite/program01 | |
parent | testsuite/syscalls01: Split out program01 part. (diff) | |
download | rtems-libbsd-3d9134086847bc755fd9dcc7f6149f8871d6a6ed.tar.bz2 |
rtemsbsd: Add call to program with a data restore
This adds the rtems_bsd_program_call_main_width_data_restore function.
Diffstat (limited to 'testsuite/program01')
-rw-r--r-- | testsuite/program01/test_main.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/program01/test_main.c b/testsuite/program01/test_main.c index 398dd62c..ca14a36d 100644 --- a/testsuite/program01/test_main.c +++ b/testsuite/program01/test_main.c @@ -170,6 +170,23 @@ no_mem_bsd_program(int fd) assert(rtems_bsd_program_get_context() == NULL); } +#define OVERWRITE_CONTENT "Some test pattern" +#define OVERWRITE_AFTER_RESTORE "xxxxxtestxxxxxxxx" +#define OVERWRITE_RESTORE_FIRST (5) +#define OVERWRITE_RESTORE_SIZE (4) +static const char overwrite_compare[] = OVERWRITE_AFTER_RESTORE; +static char overwrite_me[] = OVERWRITE_CONTENT; + +static int +overwrite_main(int argc, char **argv) +{ + size_t len = strlen(overwrite_me); + memset(overwrite_me, 'x', len); + assert(strcmp(overwrite_me, overwrite_compare) != 0); + errno = 0; + rtems_bsd_program_exit(1012); +} + static void test_bsd_program(void) { @@ -196,11 +213,15 @@ test_bsd_program(void) no_mem_bsd_program(-1); rtems_workspace_greedy_free(greedy); + assert(rtems_resource_snapshot_check(&snapshot)); + errno = 0; exit_code = rtems_bsd_program_call_main(prog_name, NULL, 1, invalid_argv); assert(errno == EFAULT); assert(exit_code == EXIT_FAILURE); + assert(rtems_resource_snapshot_check(&snapshot)); + errno = EINVAL; exit_code = rtems_bsd_program_call(prog_name, some_prog, some_context); assert(errno == 0); @@ -208,6 +229,8 @@ test_bsd_program(void) assert(strcmp(rtems_bsd_program_get_name(), "?") == 0); assert(rtems_bsd_program_get_context() == NULL); + assert(rtems_resource_snapshot_check(&snapshot)); + errno = EINVAL; exit_code = rtems_bsd_program_call_main(prog_name, some_main, some_argc, some_argv); @@ -217,6 +240,17 @@ test_bsd_program(void) assert(rtems_bsd_program_get_context() == NULL); assert(rtems_resource_snapshot_check(&snapshot)); + + exit_code = rtems_bsd_program_call_main_with_data_restore(prog_name, + overwrite_main, some_argc, some_argv, + overwrite_me + OVERWRITE_RESTORE_FIRST, OVERWRITE_RESTORE_SIZE); + assert(errno == 0); + assert(exit_code == 1012); + assert(strcmp(rtems_bsd_program_get_name(), "?") == 0); + assert(rtems_bsd_program_get_context() == NULL); + assert(strcmp(overwrite_me, overwrite_compare) == 0); + + assert(rtems_resource_snapshot_check(&snapshot)); } static void |