Changeset 3d91340 in rtems-libbsd for testsuite/program01/test_main.c


Ignore:
Timestamp:
Jul 15, 2016, 9:39:48 AM (5 years ago)
Author:
Christian Mauderer <Christian.Mauderer@…>
Branches:
b96abfd647154f10ea8f7fac68e25676636eded5, debc0aed8b9bef9996b8ec0ae7a70b0b41912e27, 68e79b6d187fe09b0a6f3f1d22c69b4121a3f76e, freebsd-9.3, 33bfaee89aa71d2252eb48d6b9a9ec17183faced
Children:
d31a365
Parents:
fa43d6a
git-author:
Christian Mauderer <Christian.Mauderer@…> (07/15/16 09:39:48)
git-committer:
Christian Mauderer <Christian.Mauderer@…> (08/02/16 08:21:38)
Message:

rtemsbsd: Add call to program with a data restore

This adds the rtems_bsd_program_call_main_width_data_restore function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuite/program01/test_main.c

    rfa43d6a r3d91340  
    171171}
    172172
     173#define OVERWRITE_CONTENT       "Some test pattern"
     174#define OVERWRITE_AFTER_RESTORE "xxxxxtestxxxxxxxx"
     175#define OVERWRITE_RESTORE_FIRST (5)
     176#define OVERWRITE_RESTORE_SIZE (4)
     177static const char overwrite_compare[] = OVERWRITE_AFTER_RESTORE;
     178static char overwrite_me[] = OVERWRITE_CONTENT;
     179
     180static int
     181overwrite_main(int argc, char **argv)
     182{
     183        size_t len = strlen(overwrite_me);
     184        memset(overwrite_me, 'x', len);
     185        assert(strcmp(overwrite_me, overwrite_compare) != 0);
     186        errno = 0;
     187        rtems_bsd_program_exit(1012);
     188}
     189
    173190static void
    174191test_bsd_program(void)
     
    197214        rtems_workspace_greedy_free(greedy);
    198215
     216        assert(rtems_resource_snapshot_check(&snapshot));
     217
    199218        errno = 0;
    200219        exit_code = rtems_bsd_program_call_main(prog_name, NULL, 1, invalid_argv);
    201220        assert(errno == EFAULT);
    202221        assert(exit_code == EXIT_FAILURE);
     222
     223        assert(rtems_resource_snapshot_check(&snapshot));
    203224
    204225        errno = EINVAL;
     
    208229        assert(strcmp(rtems_bsd_program_get_name(), "?") == 0);
    209230        assert(rtems_bsd_program_get_context() == NULL);
     231
     232        assert(rtems_resource_snapshot_check(&snapshot));
    210233
    211234        errno = EINVAL;
     
    218241
    219242        assert(rtems_resource_snapshot_check(&snapshot));
     243
     244        exit_code = rtems_bsd_program_call_main_with_data_restore(prog_name,
     245            overwrite_main, some_argc, some_argv,
     246            overwrite_me + OVERWRITE_RESTORE_FIRST, OVERWRITE_RESTORE_SIZE);
     247        assert(errno == 0);
     248        assert(exit_code == 1012);
     249        assert(strcmp(rtems_bsd_program_get_name(), "?") == 0);
     250        assert(rtems_bsd_program_get_context() == NULL);
     251        assert(strcmp(overwrite_me, overwrite_compare) == 0);
     252
     253        assert(rtems_resource_snapshot_check(&snapshot));
    220254}
    221255
Note: See TracChangeset for help on using the changeset viewer.