Commit 8b66fc69 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Add a VSL tag globbing functions test program.

parent 570a04f5
......@@ -65,7 +65,7 @@ vxp_fixed_token.c vxp_tokens.h: \
$(srcdir)/generate.py
@PYTHON@ $(srcdir)/generate.py $(srcdir) $(top_builddir)
EXTRA_PROGRAMS = vxp_test
EXTRA_PROGRAMS = vxp_test vsl_glob_test
vxp_test_LDADD = @PCRE_LIBS@ \
${RT_LIBS} ${LIBM} ${PTHREAD_LIBS}
......@@ -77,3 +77,10 @@ vxp_test_CFLAGS = \
vxp_test_SOURCES = \
$(libvarnishapi_la_SOURCES) \
vxp_test.c
vsl_glob_test_SOURCES = \
vsl_glob_test.c
vsl_glob_test_LDADD = @PCRE_LIBS@ ${RT_LIBS} ${LIBM} libvarnishapi.la
vsl_glob_test_CFLAGS = -I$(top_srcdir)/include
/*-
* Copyright (c) 2013 Varnish Software AS
* All rights reserved.
*
* Author: Martin Blix Grydeland <martin@varnish-software.com>
*
* 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.
*
* Test what VSL_Name2Tag and VSL_Glob2Tags produces
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "vas.h"
#include "vapi/vsl.h"
static void
cb(int tag, void *priv)
{
(void)priv;
printf("\t%d (%s)\n", tag, VSL_tags[tag]);
}
int
main(int argc, char *argv[])
{
int i;
if (argc != 2) {
fprintf(stderr, "vsl_glob_test <tagname/glob>\n");
exit(1);
}
i = VSL_Name2Tag(argv[1], -1);
printf("VSL_Name2Tag returns %d", i);
if (i >= 0)
printf(" (%s)", VSL_tags[i]);
printf("\n");
printf("VSL_Glob2Tags:\n");
i = VSL_Glob2Tags(argv[1], -1, cb, NULL);
printf("VSL_Glob2Tags returns %d\n", i);
printf("VSL_List2Tags:\n");
i = VSL_List2Tags(argv[1], -1, cb, NULL);
printf("VSL_List2Tags returns %d\n", i);
return (0);
}
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