mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add testcases for plugin with doctest usage
This commit is contained in:
parent
5c44dfbb9e
commit
78803b04fc
11 changed files with 113 additions and 0 deletions
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
doctest-plugin/demotest
|
|
@ -0,0 +1,7 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
[doctest] doctest version is "x.y.z"
|
||||||
|
[doctest] run with "--help" for options
|
||||||
|
===============================================================================
|
||||||
|
[doctest] test cases: 1 | 1 passed | 0 failed | XX skipped
|
||||||
|
[doctest] assertions: 1 | 1 passed | 0 failed |
|
||||||
|
[doctest] Status: SUCCESS!
|
|
@ -0,0 +1 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
12
testing/btest/plugins/doctest-disabled.zeek
Normal file
12
testing/btest/plugins/doctest-disabled.zeek
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# This requires Zeek with unit test support. The following errors if disabled.
|
||||||
|
# @TEST-REQUIRES: zeek --test -h >/dev/null
|
||||||
|
|
||||||
|
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Doctest
|
||||||
|
# @TEST-EXEC: cp -r %DIR/doctest-plugin/* .
|
||||||
|
|
||||||
|
# Build the plugin without unit-test support.
|
||||||
|
# @TEST-EXEC: ./configure --disable-cpp-tests --zeek-dist=${DIST} && make
|
||||||
|
#
|
||||||
|
# List the plugin's test names -- there shouldn't be any.
|
||||||
|
# @TEST-EXEC: ZEEK_PLUGIN_ACTIVATE="Demo::Doctest" ZEEK_PLUGIN_PATH=`pwd` zeek --test -ltc | grep doctest-plugin >testnames || true
|
||||||
|
# @TEST-EXEC: btest-diff testnames
|
0
testing/btest/plugins/doctest-plugin/.btest-ignore
Normal file
0
testing/btest/plugins/doctest-plugin/.btest-ignore
Normal file
25
testing/btest/plugins/doctest-plugin/src/Plugin.cc
Normal file
25
testing/btest/plugins/doctest-plugin/src/Plugin.cc
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
#include "Plugin.h"
|
||||||
|
|
||||||
|
#include <zeek/3rdparty/doctest.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace btest::plugin::Demo_Doctest { Plugin plugin; }
|
||||||
|
|
||||||
|
using namespace btest::plugin::Demo_Doctest;
|
||||||
|
|
||||||
|
zeek::plugin::Configuration Plugin::Configure()
|
||||||
|
{
|
||||||
|
zeek::plugin::Configuration config;
|
||||||
|
config.name = "Demo::Doctest";
|
||||||
|
config.description = "Run doctest in a unit-test enabled build";
|
||||||
|
config.version.major = 1;
|
||||||
|
config.version.minor = 0;
|
||||||
|
config.version.patch = 0;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("doctest-plugin/demotest")
|
||||||
|
{
|
||||||
|
CHECK(true);
|
||||||
|
}
|
17
testing/btest/plugins/doctest-plugin/src/Plugin.h
Normal file
17
testing/btest/plugins/doctest-plugin/src/Plugin.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <zeek/plugin/Plugin.h>
|
||||||
|
|
||||||
|
namespace btest::plugin::Demo_Doctest {
|
||||||
|
|
||||||
|
class Plugin : public zeek::plugin::Plugin
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
// Overridden from zeek::plugin::Plugin.
|
||||||
|
zeek::plugin::Configuration Configure() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Plugin plugin;
|
||||||
|
|
||||||
|
}
|
18
testing/btest/plugins/doctest-supported.zeek
Normal file
18
testing/btest/plugins/doctest-supported.zeek
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# This requires Zeek with unit test support. The following errors if disabled.
|
||||||
|
# @TEST-REQUIRES: zeek --test -h >/dev/null
|
||||||
|
|
||||||
|
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Doctest
|
||||||
|
# @TEST-EXEC: cp -r %DIR/doctest-plugin/* .
|
||||||
|
|
||||||
|
# Build the plugin with unit-test support. Zeek supports it, so we should
|
||||||
|
# get runnable tests.
|
||||||
|
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make
|
||||||
|
#
|
||||||
|
# List the plugin's test names.
|
||||||
|
# @TEST-EXEC: ZEEK_PLUGIN_ACTIVATE="Demo::Doctest" ZEEK_PLUGIN_PATH=`pwd` zeek --test -ltc | grep doctest-plugin >testnames
|
||||||
|
# @TEST-EXEC: btest-diff testnames
|
||||||
|
|
||||||
|
# The seed file affects some of the unit tests, so we unset it.
|
||||||
|
# Running the unit tests implies deterministic mode, -D.
|
||||||
|
# @TEST-EXEC: ZEEK_SEED_FILE= ZEEK_PLUGIN_ACTIVATE="Demo::Doctest" ZEEK_PLUGIN_PATH=`pwd` zeek --test --test-case='doctest-plugin/*' >testresults
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=diff-clean-doctest btest-diff testresults
|
13
testing/btest/plugins/doctest-unsupported.zeek
Normal file
13
testing/btest/plugins/doctest-unsupported.zeek
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# This requires Zeek without unit test support. The following errors if enabled.
|
||||||
|
# @TEST-REQUIRES: ! zeek --test -h >/dev/null
|
||||||
|
|
||||||
|
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Doctest
|
||||||
|
# @TEST-EXEC: cp -r %DIR/doctest-plugin/* .
|
||||||
|
|
||||||
|
# Build the plugin without disabling unit testing. Zeek doesn't support it,
|
||||||
|
# so the plugin should automatically build without it.
|
||||||
|
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make
|
||||||
|
#
|
||||||
|
# List the plugin's test names -- there shouldn't be any.
|
||||||
|
# @TEST-EXEC: ZEEK_PLUGIN_ACTIVATE="Demo::Doctest" ZEEK_PLUGIN_PATH=`pwd` zeek --test -ltc | grep doctest-plugin >testnames || true
|
||||||
|
# @TEST-EXEC: btest-diff testnames
|
17
testing/scripts/diff-clean-doctest
Executable file
17
testing/scripts/diff-clean-doctest
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
#
|
||||||
|
# doctest's console reports contain several aspects that change over time:
|
||||||
|
# - The total number of tests, which we replace with "XX"
|
||||||
|
# - The version number, which becomes "x.y.z"
|
||||||
|
# - Spacing in the report, which we normalize to single spaces
|
||||||
|
|
||||||
|
# Get us "modern" regexps with sed.
|
||||||
|
if [ $(uname) == "Linux" ]; then
|
||||||
|
sed="sed -r"
|
||||||
|
else
|
||||||
|
sed="sed -E"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$sed -e 's/[0-9]+ skipped/XX skipped/g' |
|
||||||
|
$sed -e 's/"[0-9]+\.[0-9]+\.[0-9]+"/"x.y.z"/g' |
|
||||||
|
$sed -e 's/ {2,}/ /g'
|
Loading…
Add table
Add a link
Reference in a new issue