Spdk/test/event/app_repeat/app_repeat.c
paul luse a6dbe3721e update Intel copyright notices
per Intel policy to include file commit date using git cmd
below.  The policy does not apply to non-Intel (C) notices.

git log --follow -C90% --format=%ad --date default <file> | tail -1

and then pull just the 4 digit year from the result.

Intel copyrights were not added to files where Intel either had
no contribution ot the contribution lacked substance (ie license
header updates, formatting changes, etc).  Contribution date used
"--follow -C95%" to get the most accurate date.

Note that several files in this patch didn't end the license/(c)
block with a blank comment line so these were added as the vast
majority of files do have this last blank line.  Simply there for
consistency.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Id5b7ce4f658fe87132f14139ead58d6e285c04d4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15192
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
2022-11-10 08:28:53 +00:00

80 lines
1.5 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (C) 2020 Intel Corporation.
* All rights reserved.
*/
#include "spdk/stdinc.h"
#include "spdk/event.h"
#include "spdk/string.h"
#include "spdk/thread.h"
struct spdk_app_opts g_opts = {};
static const char g_app_repeat_get_opts_string[] = "t:";
static int g_repeat_times = 2;
static void
app_repeat_usage(void)
{
printf(" -t <num> number of times to repeat calling spdk_app_start/stop\n");
}
static int
app_repeat_parse_arg(int ch, char *arg)
{
switch (ch) {
case 't':
g_repeat_times = spdk_strtol(arg, 0);
if (g_repeat_times < 2) {
return -EINVAL;
}
break;
default:
return -EINVAL;
}
return 0;
}
static void
app_repeat_started(void *arg1)
{
int index = *(int *)arg1;
printf("spdk_app_start is called in Round %d.\n", index);
}
static void
_app_repeat_shutdown_cb(void)
{
printf("Shutdown signal received, stop current app iteration\n");
spdk_app_stop(0);
}
int
main(int argc, char **argv)
{
int rc;
int i;
spdk_app_opts_init(&g_opts, sizeof(g_opts));
g_opts.name = "app_repeat";
g_opts.shutdown_cb = _app_repeat_shutdown_cb;
if ((rc = spdk_app_parse_args(argc, argv, &g_opts, g_app_repeat_get_opts_string,
NULL, app_repeat_parse_arg, app_repeat_usage)) !=
SPDK_APP_PARSE_ARGS_SUCCESS) {
return rc;
}
for (i = 0; i < g_repeat_times; i++) {
rc = spdk_app_start(&g_opts, app_repeat_started, &i);
spdk_app_fini();
if (rc) {
fprintf(stderr, "Failed to call spdk_app_start in Round %d.\n", i);
break;
}
}
return rc;
}