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

Get rid of the hardcoded lists of programs and vmods, instead

read the actual directories and filter on prefix strings.
parent 0c3ec169
/*-
* Copyright (c) 2013 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
VTC_PROG(haproxy)
VTC_PROG(varnishadm)
VTC_PROG(varnishd)
VTC_PROG(varnishhist)
VTC_PROG(varnishlog)
VTC_PROG(varnishncsa)
VTC_PROG(varnishstat)
VTC_PROG(varnishtest)
VTC_PROG(varnishtop)
#undef VTC_PROG
/*-
* Copyright (c) 2013 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
VTC_VMOD(std)
VTC_VMOD(debug)
VTC_VMOD(directors)
VTC_VMOD(purge)
VTC_VMOD(vtc)
VTC_VMOD(blob)
VTC_VMOD(unix)
VTC_VMOD(proxy)
......@@ -35,12 +35,14 @@
#include <sys/wait.h>
#include <ctype.h>
#include <dirent.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include "vtc.h"
......@@ -458,14 +460,44 @@ start_test(void)
* Find the abs path to top of source dir from Makefile, if that
* fails, fall back on "../../"
*
* Set path to all programs build directories
* Set PATH to all programs build directories
* Set vmod_path to all vmods build directories
*
*/
static void
build_path(const char *topbuilddir, const char *subdir,
const char *pfx, const char *sfx, struct vsb *vsb)
{
char buf[PATH_MAX];
DIR *dir;
struct dirent *de;
struct stat st;
const char *sep = "";
bprintf(buf, "%s/%s/", topbuilddir, subdir);
dir = opendir(buf);
XXXAN(dir);
while (1) {
de = readdir(dir);
if (de == NULL)
break;
if (strncmp(de->d_name, pfx, strlen(pfx)))
continue;
bprintf(buf, "%s/%s/%s", topbuilddir, subdir, de->d_name);
if (!stat(buf, &st) && S_ISDIR(st.st_mode)) {
VSB_cat(vsb, sep);
VSB_cat(vsb, buf);
VSB_cat(vsb, sfx);
sep = ":";
}
}
AZ(closedir(dir));
}
static void
i_mode(void)
{
const char *sep;
struct vsb *vsb;
char *p, *q;
char *topbuild;
......@@ -511,39 +543,27 @@ i_mode(void)
}
AN(topbuild);
extmacro_def("topbuild", "%s", topbuild);
/*
* Build $PATH which can find all programs in the build tree
*/
VSB_clear(vsb);
VSB_cat(vsb, "PATH=");
sep = "";
#define VTC_PROG(l) \
do { \
VSB_printf(vsb, "%s%s/bin/" #l, sep, topbuild); \
sep = ":"; \
} while (0);
#include "programs.h"
build_path(topbuild, "bin", "varnish", "", vsb);
VSB_printf(vsb, ":%s", getenv("PATH"));
AZ(VSB_finish(vsb));
AZ(putenv(strdup(VSB_data(vsb))));
/*
* Build vmod_path which can find all VMODs in the build tree
*/
VSB_clear(vsb);
sep = "";
#define VTC_VMOD(l) \
do { \
VSB_printf(vsb, "%s%s/lib/libvmod_" #l "/.libs", \
sep, topbuild); \
sep = ":"; \
} while (0);
#include "vmods.h"
#undef VTC_VMOD
build_path(topbuild, "lib", "libvmod_", "/.libs", vsb);
AZ(VSB_finish(vsb));
vmod_path = strdup(VSB_data(vsb));
AN(vmod_path);
free(topbuild);
VSB_destroy(&vsb);
......
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