Commit f0dc9964 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Implement "include file ..." command

Submitted by: @AlveElde in Vtest repo on github
parent 1e03c7b9
......@@ -37,6 +37,7 @@
CMD_GLOBAL(barrier)
CMD_GLOBAL(delay)
CMD_GLOBAL(shell)
CMD_GLOBAL(include)
#undef CMD_GLOBAL
#ifndef CMD_TOP
......
......@@ -48,6 +48,7 @@
#include "vtc.h"
#include "vfil.h"
#include "vnum.h"
#include "vre.h"
#include "vtcp.h"
......@@ -349,6 +350,40 @@ cmd_delay(CMD_ARGS)
VTIM_sleep(f);
}
/* SECTION: include include
*
* Executes a vtc fragment::
*
* include FILE [...]
*
* Open a file and execute it as a VTC fragment. This command is available
* everywhere commands are given.
*
*/
void
cmd_include(CMD_ARGS)
{
char *spec;
unsigned i;
if (av == NULL)
return;
if (av[1] == NULL)
vtc_fatal(vl, "CMD include: At least 1 argument required");
for (i = 1; av[i] != NULL; i++) {
spec = VFIL_readfile(NULL, av[i], NULL);
if (spec == NULL)
vtc_fatal(vl, "CMD include: Unable to read file '%s' "
"(%s)", av[i], strerror(errno));
vtc_log(vl, 2, "Begin include '%s'", av[i]);
parse_string(vl, priv, spec);
vtc_log(vl, 2, "End include '%s'", av[i]);
free(spec);
}
}
/**********************************************************************
* Most test-cases use only numeric IP#'s but a few requires non-demented
* DNS services. This is a basic sanity check for those.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment