native_simulator: Get latest from upstream
Align with native_simulator's upstream main 3eae4374db5984a5defcefdeda254b37e72e2ca8 Which includes: * 3eae437 cmdline parsing: Allow providing more arguments progammatically * d148a28 Host trampolines: Add realloc Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
6a1f48bd4e
commit
5a2641b1d7
4 changed files with 36 additions and 0 deletions
|
@ -18,6 +18,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void nsi_handle_cmd_line(int argc, char *argv[]);
|
void nsi_handle_cmd_line(int argc, char *argv[]);
|
||||||
|
void nsi_register_extra_args(int argc, char *argv[]);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ int nsi_host_open(const char *pathname, int flags);
|
||||||
/* int nsi_host_printf (const char *fmt, ...); Use the nsi_tracing.h equivalents */
|
/* int nsi_host_printf (const char *fmt, ...); Use the nsi_tracing.h equivalents */
|
||||||
long nsi_host_random(void);
|
long nsi_host_random(void);
|
||||||
long nsi_host_read(int fd, void *buffer, unsigned long size);
|
long nsi_host_read(int fd, void *buffer, unsigned long size);
|
||||||
|
void *nsi_host_realloc(void *ptr, unsigned long size);
|
||||||
void nsi_host_srandom(unsigned int seed);
|
void nsi_host_srandom(unsigned int seed);
|
||||||
char *nsi_host_strdup(const char *s);
|
char *nsi_host_strdup(const char *s);
|
||||||
long nsi_host_write(int fd, void *buffer, unsigned long size);
|
long nsi_host_write(int fd, void *buffer, unsigned long size);
|
||||||
|
|
|
@ -56,6 +56,11 @@ long nsi_host_read(int fd, void *buffer, unsigned long size)
|
||||||
return read(fd, buffer, size);
|
return read(fd, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *nsi_host_realloc(void *ptr, unsigned long size)
|
||||||
|
{
|
||||||
|
return realloc(ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
void nsi_host_srandom(unsigned int seed)
|
void nsi_host_srandom(unsigned int seed)
|
||||||
{
|
{
|
||||||
srandom(seed);
|
srandom(seed);
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
static int s_argc, test_argc;
|
static int s_argc, test_argc;
|
||||||
static char **s_argv, **test_argv;
|
static char **s_argv, **test_argv;
|
||||||
|
|
||||||
|
/* Extra "command line options" provided programmatically: */
|
||||||
|
static int extra_argc;
|
||||||
|
static char **extra_argv;
|
||||||
|
|
||||||
static struct args_struct_t *args_struct;
|
static struct args_struct_t *args_struct;
|
||||||
static int used_args;
|
static int used_args;
|
||||||
static int args_aval;
|
static int args_aval;
|
||||||
|
@ -119,6 +123,13 @@ void nsi_handle_cmd_line(int argc, char *argv[])
|
||||||
|
|
||||||
nsi_cmd_args_set_defaults(args_struct);
|
nsi_cmd_args_set_defaults(args_struct);
|
||||||
|
|
||||||
|
for (int i = 0; i < extra_argc; i++) {
|
||||||
|
if (!nsi_cmd_parse_one_arg(extra_argv[i], args_struct)) {
|
||||||
|
nsi_cmd_print_switches_help(args_struct);
|
||||||
|
print_invalid_opt_error(extra_argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
|
||||||
if ((nsi_cmd_is_option(argv[i], "testargs", 0))) {
|
if ((nsi_cmd_is_option(argv[i], "testargs", 0))) {
|
||||||
|
@ -134,6 +145,24 @@ void nsi_handle_cmd_line(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsi_register_extra_args(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int new_size = extra_argc + argc;
|
||||||
|
|
||||||
|
extra_argv = realloc(extra_argv, new_size*sizeof(char *));
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
memcpy(&extra_argv[extra_argc], argv, argc*sizeof(char *));
|
||||||
|
}
|
||||||
|
extra_argc += argc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clear_extra_args(void)
|
||||||
|
{
|
||||||
|
free(extra_argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
NSI_TASK(clear_extra_args, ON_EXIT_PRE, 100);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application/test can use this function to inspect all the command line
|
* The application/test can use this function to inspect all the command line
|
||||||
* arguments
|
* arguments
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue