CI: update ansible tests for re2 (#2318)
This commit is contained in:
parent
bd41f855cf
commit
17cd792826
29 changed files with 838 additions and 39 deletions
|
@ -9,11 +9,10 @@ WORKDIR /go/src/crowdsec
|
||||||
ENV RE2_VERSION=2023-03-01
|
ENV RE2_VERSION=2023-03-01
|
||||||
|
|
||||||
# wizard.sh requires GNU coreutils
|
# wizard.sh requires GNU coreutils
|
||||||
RUN apk add --no-cache git g++ gcc libc-dev make bash gettext binutils-gold coreutils icu-static pkgconfig && \
|
RUN apk add --no-cache git g++ gcc libc-dev make bash gettext binutils-gold coreutils pkgconfig && \
|
||||||
wget https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz && \
|
wget https://github.com/google/re2/archive/refs/tags/${RE2_VERSION}.tar.gz && \
|
||||||
tar -xzf ${RE2_VERSION}.tar.gz && \
|
tar -xzf ${RE2_VERSION}.tar.gz && \
|
||||||
cd re2-${RE2_VERSION} && \
|
cd re2-${RE2_VERSION} && \
|
||||||
make && \
|
|
||||||
make install && \
|
make install && \
|
||||||
echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
|
echo "githubciXXXXXXXXXXXXXXXXXXXXXXXX" > /etc/machine-id && \
|
||||||
go install github.com/mikefarah/yq/v4@v4.34.1
|
go install github.com/mikefarah/yq/v4@v4.34.1
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -17,7 +17,7 @@ BUILD_RE2_WASM ?= 0
|
||||||
|
|
||||||
# To build static binaries, run "make BUILD_STATIC=1".
|
# To build static binaries, run "make BUILD_STATIC=1".
|
||||||
# On some platforms, this requires
|
# On some platforms, this requires
|
||||||
# additional packages (e.g. glibc-static on fedora, centos..).
|
# additional packages (e.g. glibc-static and libstdc++-static on fedora, centos..).
|
||||||
# If the static build fails at the link stage, it might be because the static library is not provided
|
# If the static build fails at the link stage, it might be because the static library is not provided
|
||||||
# for your distribution (look for libre2.a). See the Dockerfile for an example of how to build it.
|
# for your distribution (look for libre2.a). See the Dockerfile for an example of how to build it.
|
||||||
BUILD_STATIC ?= 0
|
BUILD_STATIC ?= 0
|
||||||
|
@ -77,10 +77,14 @@ LD_OPTS_VARS += -X '$(GO_MODULE_NAME)/pkg/cwversion.System=docker'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GO_TAGS := netgo,osusergo,sqlite_omit_load_extension
|
GO_TAGS := netgo,osusergo,sqlite_omit_load_extension
|
||||||
|
# this will be used by Go in the make target
|
||||||
|
export PKG_CONFIG_PATH:=/usr/local/lib/pkgconfig:$(PKG_CONFIG_PATH)
|
||||||
|
|
||||||
ifeq ($(call bool,$(BUILD_RE2_WASM)),0)
|
ifeq ($(call bool,$(BUILD_RE2_WASM)),0)
|
||||||
# see if we have libre2-dev installed for C++ optimizations
|
ifeq ($(PKG_CONFIG),)
|
||||||
RE2_CHECK := $(shell pkg-config --libs re2 2>/dev/null)
|
$(error "pkg-config is not available. Please install pkg-config.")
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(RE2_CHECK),)
|
ifeq ($(RE2_CHECK),)
|
||||||
# we could detect the platform and suggest the command to install
|
# we could detect the platform and suggest the command to install
|
||||||
RE2_FAIL := "libre2-dev is not installed, please install it or set BUILD_RE2_WASM=1 to use the WebAssembly version"
|
RE2_FAIL := "libre2-dev is not installed, please install it or set BUILD_RE2_WASM=1 to use the WebAssembly version"
|
||||||
|
|
5
go.mod
5
go.mod
|
@ -65,7 +65,7 @@ require (
|
||||||
github.com/prometheus/prom2json v1.3.0
|
github.com/prometheus/prom2json v1.3.0
|
||||||
github.com/r3labs/diff/v2 v2.14.1
|
github.com/r3labs/diff/v2 v2.14.1
|
||||||
github.com/segmentio/kafka-go v0.4.34
|
github.com/segmentio/kafka-go v0.4.34
|
||||||
github.com/shirou/gopsutil/v3 v3.22.12
|
github.com/shirou/gopsutil/v3 v3.23.5
|
||||||
github.com/sirupsen/logrus v1.9.2
|
github.com/sirupsen/logrus v1.9.2
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.7.0
|
||||||
github.com/stretchr/testify v1.8.3
|
github.com/stretchr/testify v1.8.3
|
||||||
|
@ -163,6 +163,7 @@ require (
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
github.com/shopspring/decimal v1.2.0 // indirect
|
github.com/shopspring/decimal v1.2.0 // indirect
|
||||||
github.com/spf13/cast v1.3.1 // indirect
|
github.com/spf13/cast v1.3.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
@ -172,7 +173,7 @@ require (
|
||||||
github.com/tklauser/numcpus v0.6.0 // indirect
|
github.com/tklauser/numcpus v0.6.0 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.6 // indirect
|
github.com/ugorji/go/codec v1.2.6 // indirect
|
||||||
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
||||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||||
github.com/zclconf/go-cty v1.8.0 // indirect
|
github.com/zclconf/go-cty v1.8.0 // indirect
|
||||||
go.mongodb.org/mongo-driver v1.9.4 // indirect
|
go.mongodb.org/mongo-driver v1.9.4 // indirect
|
||||||
golang.org/x/net v0.7.0 // indirect
|
golang.org/x/net v0.7.0 // indirect
|
||||||
|
|
15
go.sum
15
go.sum
|
@ -831,8 +831,12 @@ github.com/segmentio/kafka-go v0.4.34 h1:Dm6YlLMiVSiwwav20KY0AoY63s661FXevwJ3CVH
|
||||||
github.com/segmentio/kafka-go v0.4.34/go.mod h1:GAjxBQJdQMB5zfNA21AhpaqOB2Mu+w3De4ni3Gbm8y0=
|
github.com/segmentio/kafka-go v0.4.34/go.mod h1:GAjxBQJdQMB5zfNA21AhpaqOB2Mu+w3De4ni3Gbm8y0=
|
||||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||||
github.com/shirou/gopsutil/v3 v3.22.12 h1:oG0ns6poeUSxf78JtOsfygNWuEHYYz8hnnNg7P04TJs=
|
github.com/shirou/gopsutil/v3 v3.23.5 h1:5SgDCeQ0KW0S4N0znjeM/eFHXXOKyv2dVNgRq/c9P6Y=
|
||||||
github.com/shirou/gopsutil/v3 v3.22.12/go.mod h1:Xd7P1kwZcp5VW52+9XsirIKd/BROzbb2wdX3Kqlz9uI=
|
github.com/shirou/gopsutil/v3 v3.23.5/go.mod h1:Ng3Maa27Q2KARVJ0SPZF5NdrQSC3XHKP8IIWrHgMeLY=
|
||||||
|
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||||
|
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||||
|
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
|
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
||||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
|
@ -883,7 +887,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
|
@ -937,8 +940,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
|
||||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
|
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
|
||||||
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
||||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||||
|
@ -1203,7 +1206,7 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
||||||
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
|
733
mk/gmsl.html
Normal file
733
mk/gmsl.html
Normal file
|
@ -0,0 +1,733 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<html><head>
|
||||||
|
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
|
||||||
|
<title>GNU Make Standard Library</title></head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>GNU Make Standard Library</h1>
|
||||||
|
The GNU Make Standard Library (GMSL) is a collection of functions
|
||||||
|
implemented using native GNU Make functionality that provide list and
|
||||||
|
string manipulation, integer arithmetic, associative arrays, stacks,
|
||||||
|
and debugging facilities. The GMSL is released under the BSD License.<br>
|
||||||
|
<br>
|
||||||
|
<a href="https://github.com/jgrahamc/gmsl/">[Project Page]</a>
|
||||||
|
<a href="https://github.com/jgrahamc/gmsl/releases/">[Releases]</a>
|
||||||
|
<br>
|
||||||
|
<h2>Using GMSL</h2>
|
||||||
|
The two files needed are <span style="font-family: monospace;">gmsl</span>
|
||||||
|
and <span style="font-family: monospace;">__gmsl</span>. To
|
||||||
|
include the GMSL in your Makefile do<br>
|
||||||
|
<pre style="margin-left: 40px;">include gmsl</pre>
|
||||||
|
<span style="font-family: monospace;">gmsl</span> automatically includes<span style="font-family: monospace;"> __gmsl</span>. To check that
|
||||||
|
you have the right version of <span style="font-family: monospace;">gmsl</span>
|
||||||
|
use the <span style="font-family: monospace;">gmsl_compatible</span>
|
||||||
|
function (see
|
||||||
|
below). The current version is <span style="font-family: monospace;">1 2 0</span>.<br>
|
||||||
|
<br>
|
||||||
|
The GMSL package also includes a test suite for GMSL. Just run <span style="font-family: monospace;">make -f gmsl-tests</span>.<br>
|
||||||
|
<h2>Logical Operators</h2>GMSL has boolean $(true) (a non-empty string)
|
||||||
|
and $(false) (an empty string). The following operators can be
|
||||||
|
used with those variables.<br>
|
||||||
|
<br>
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-weight: bold;">not</span><br>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<span style="font-family: monospace;">Arguments: A boolean value</span><br style="font-family: monospace;">
|
||||||
|
|
||||||
|
<span style="font-family: monospace;">Returns: Returns $(true) if the boolean is $(false) and vice versa</span><br style="font-family: monospace;">
|
||||||
|
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;"></span><span style="font-weight: bold;">and</span><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
|
||||||
|
<span style="font-family: monospace;">Returns: Returns $(true) if both of the booleans are true</span><br style="font-family: monospace;">
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">or</span><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
|
||||||
|
<span style="font-family: monospace;">Returns: Returns $(true) if either of the booleans is true</span><br style="font-family: monospace;">
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">xor</span><br style="font-weight: bold;">
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
|
||||||
|
<span style="font-family: monospace;">Returns: Returns $(true) if exactly one of the booleans is true</span><br style="font-family: monospace;">
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">nand</span><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
|
||||||
|
<span style="font-family: monospace;">Returns: Returns value of 'not and'</span><br style="font-family: monospace;">
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">nor</span><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
|
||||||
|
<span style="font-family: monospace;">Returns: Returns value of 'not or'</span><br style="font-family: monospace;">
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">xnor</span><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;">
|
||||||
|
<span style="font-family: monospace;">Returns: Returns value of 'not xor'</span><br style="font-family: monospace;">
|
||||||
|
<hr style="width: 100%; height: 2px; font-family: monospace;">
|
||||||
|
<h2>List Manipulation Functions</h2>
|
||||||
|
A list is a string of characters; the list separator is a space.<br>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<hr style="width: 100%; height: 2px;"><b>first</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list<br>
|
||||||
|
Returns: Returns the first element of a list<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>last</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list<br>
|
||||||
|
Returns: Returns the last element of a list<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>rest</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list<br>
|
||||||
|
Returns: Returns the list with the first element
|
||||||
|
removed<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>chop</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list<br>
|
||||||
|
Returns: Returns the list with the last element removed<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>map</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of function to
|
||||||
|
$(call) for each element of list<br>
|
||||||
|
2: List to
|
||||||
|
iterate over calling the function in 1<br>
|
||||||
|
Returns: The list after calling the function on each
|
||||||
|
element<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>pairmap</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of function to
|
||||||
|
$(call) for each pair of elements<br>
|
||||||
|
2: List to
|
||||||
|
iterate over calling the function in 1<br>
|
||||||
|
3: Second
|
||||||
|
list to iterate over calling the function in 1<br>
|
||||||
|
Returns: The list after calling the function on each
|
||||||
|
pair of elements<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>leq</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list to compare
|
||||||
|
against...<br>
|
||||||
|
2: ...this
|
||||||
|
list<br>
|
||||||
|
Returns: Returns $(true) if the two lists are identical<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>lne</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list to compare
|
||||||
|
against...<br>
|
||||||
|
2: ...this
|
||||||
|
list<br>
|
||||||
|
Returns: Returns $(true) if the two lists are different<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>reverse</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list to reverse<br>
|
||||||
|
Returns: The list with its elements in reverse order<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>uniq</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list to deduplicate<br>
|
||||||
|
Returns: The list with elements in order without duplicates<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>length</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list<br>
|
||||||
|
Returns: The number of elements in the list<br>
|
||||||
|
</span>
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>String Manipulation Functions</h2>
|
||||||
|
A string is any sequence of characters.<br>
|
||||||
|
<br>
|
||||||
|
<hr style="width: 100%; height: 2px;"><b>seq</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A string to compare
|
||||||
|
against...<br>
|
||||||
|
2: ...this
|
||||||
|
string<br>
|
||||||
|
Returns: Returns $(true) if the two strings are
|
||||||
|
identical<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>sne</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A string to compare
|
||||||
|
against...<br>
|
||||||
|
2: ...this
|
||||||
|
string<br>
|
||||||
|
Returns: Returns $(true) if the two strings are not
|
||||||
|
the same<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>strlen</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A string<br>
|
||||||
|
Returns: Returns the length of the string<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>substr</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A string<br>
|
||||||
|
2: Start offset (first character is 1)<br>
|
||||||
|
3: Ending offset (inclusive)<br>Returns: Returns a substring<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>split</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: The character to
|
||||||
|
split on<br>
|
||||||
|
2: A
|
||||||
|
string to split<br>
|
||||||
|
Returns: Splits a string into a list separated by
|
||||||
|
spaces at the split<br>
|
||||||
|
character
|
||||||
|
in the first argument<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>merge</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: The character to
|
||||||
|
put between fields<br>
|
||||||
|
2: A list
|
||||||
|
to merge into a string<br>
|
||||||
|
Returns: Merges a list into a single string, list
|
||||||
|
elements are separated<br>
|
||||||
|
by the
|
||||||
|
character in the first argument<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>tr</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: The list of
|
||||||
|
characters to translate from <br>
|
||||||
|
2: The
|
||||||
|
list of characters to translate to<br>
|
||||||
|
3: The
|
||||||
|
text to translate<br>
|
||||||
|
Returns: Returns the text after translating characters<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>uc</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Text to upper case<br>
|
||||||
|
Returns: Returns the text in upper case<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>lc</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Text to lower case<br>
|
||||||
|
Returns: Returns the text in lower case<br>
|
||||||
|
</span>
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>Set Manipulation Functions</h2>
|
||||||
|
Sets are represented by sorted, deduplicated lists. To create a set
|
||||||
|
from a list use <span style="font-family:
|
||||||
|
monospace;">set_create</span>, or start with the <span
|
||||||
|
style="font-family: monospace;">empty_set</span> and <span
|
||||||
|
style="font-family: monospace;">set_insert</span> individual elements.
|
||||||
|
The empty set is defined as <span style="font-family:
|
||||||
|
monospace;">empty_set</span>.<p>
|
||||||
|
|
||||||
|
<hr><b>set_create</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A list of set elements<br>
|
||||||
|
Returns: Returns the newly created set<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_insert</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A single element to add to a set<br>
|
||||||
|
2: A set<br>
|
||||||
|
Returns: Returns the set with the element added<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_remove</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A single element to remove from a set<br>
|
||||||
|
2: A set<br>
|
||||||
|
Returns: Returns the set with the element removed<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_is_member</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A single element<br>
|
||||||
|
2: A set<br>
|
||||||
|
Returns: Returns $(true) if the element is in the set<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_is_not_member</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A single element<br>
|
||||||
|
2: A set<br>
|
||||||
|
Returns: Returns $(false) if the element is in the set<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_union</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A set<br>
|
||||||
|
2: Another set<br>
|
||||||
|
Returns: Returns the union of the two sets<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_intersection</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A set<br>
|
||||||
|
2: Another set<br>
|
||||||
|
Returns: Returns the intersection of the two sets<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_is_subset</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A set<br>
|
||||||
|
2: Another set<br>
|
||||||
|
Returns: Returns $(true) if the first set is a subset of the second<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr><b>set_equal</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A set<br>
|
||||||
|
2: Another set<br>
|
||||||
|
Returns: Returns $(true) if the two sets are identical<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>Integer Arithmetic Functions</h2>
|
||||||
|
Integers are represented by lists with the equivalent number of
|
||||||
|
x's. For example the number 4 is x x x x. The maximum
|
||||||
|
integer that the library can handle as <span style="font-style: italic;">input</span> (i.e. as the argument to a
|
||||||
|
call to <span style="font-family: monospace;">int_encode</span>) is
|
||||||
|
65536. There is no limit on integer size for internal computations or
|
||||||
|
output.<br>
|
||||||
|
<br>
|
||||||
|
The arithmetic library functions come in two forms: one form of each
|
||||||
|
function takes integers as arguments and the other form takes the
|
||||||
|
encoded form (x's created by a call to <span style="font-family: monospace;">int_encode</span>). For example,
|
||||||
|
there are two plus functions: <span style="font-family: monospace;">plus</span>
|
||||||
|
(called with integer arguments and returns an integer) and <span style="font-family: monospace;">int_plus</span> (called with encoded
|
||||||
|
arguments and returns an encoded result).<br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">plus</span> will be slower than <span style="font-family: monospace;">int_plus</span> because its arguments
|
||||||
|
and result have to be translated between the x's format and
|
||||||
|
integers. If doing a complex calculation use the <span style="font-family: monospace;">int_*</span> forms with a single
|
||||||
|
encoding of inputs and single decoding of the output. For simple
|
||||||
|
calculations the direct forms can be used.<br>
|
||||||
|
<br>
|
||||||
|
<hr style="width: 100%; height: 2px;"><b>int_decode</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number of x's
|
||||||
|
representation<br>
|
||||||
|
Returns: Returns the integer for human consumption
|
||||||
|
that is represented<br>
|
||||||
|
by the
|
||||||
|
string of x's<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_encode</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in
|
||||||
|
human-readable integer form<br>
|
||||||
|
Returns: Returns the integer encoded as a string of x's<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_plus</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
2: Another
|
||||||
|
number in x's represntation<br>
|
||||||
|
Returns: Returns the sum of the two numbers in x's
|
||||||
|
representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>plus (wrapped version of int_plus)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: Another
|
||||||
|
integer<br>
|
||||||
|
Returns: Returns the sum of the two integers<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_subtract</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
2: Another
|
||||||
|
number in x's represntation<br>
|
||||||
|
Returns: Returns the difference of the two numbers in
|
||||||
|
x's representation,<br>
|
||||||
|
or outputs
|
||||||
|
an error on a numeric underflow<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>subtract (wrapped version of int_subtract)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: Another
|
||||||
|
integer<br>
|
||||||
|
Returns: Returns the difference of the two integers,<br>
|
||||||
|
or outputs
|
||||||
|
an error on a numeric underflow<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_multiply</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
2: Another
|
||||||
|
number in x's represntation<br>
|
||||||
|
Returns: Returns the product of the two numbers in x's
|
||||||
|
representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>multiply (wrapped version of int_multiply)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: Another
|
||||||
|
integer<br>
|
||||||
|
Returns: Returns the product of the two integers<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_divide</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
2: Another
|
||||||
|
number in x's represntation<br>
|
||||||
|
Returns: Returns the result of integer division of
|
||||||
|
argument 1 divided<br>
|
||||||
|
by
|
||||||
|
argument 2 in x's representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>divide (wrapped version of int_divide)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: Another
|
||||||
|
integer<br>
|
||||||
|
Returns: Returns the integer division of the first
|
||||||
|
argument by the second<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_modulo</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
2: Another
|
||||||
|
number in x's represntation<br>
|
||||||
|
Returns: Returns the remainder of integer division of
|
||||||
|
argument 1 divided<br>
|
||||||
|
by
|
||||||
|
argument 2 in x's representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>modulo (wrapped version of int_modulo)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: Another
|
||||||
|
integer<br>
|
||||||
|
Returns: Returns the remainder of integer division of the first
|
||||||
|
argument by the second<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_max, int_min</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
2: Another
|
||||||
|
number in x's represntation<br>
|
||||||
|
Returns: Returns the maximum or minimum of its
|
||||||
|
arguments in x's<br>
|
||||||
|
|
||||||
|
representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>max, min</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: Another
|
||||||
|
integer<br>
|
||||||
|
Returns: Returns the maximum or minimum of its integer
|
||||||
|
arguments<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_gt, int_gte, int_lt, int_lte, int_eq, int_ne</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two x's representation
|
||||||
|
numbers to be compared<br>
|
||||||
|
Returns: $(true) or $(false)<br>
|
||||||
|
<br>
|
||||||
|
int_gt First argument greater than second argument<br>
|
||||||
|
int_gte First argument greater than or equal to second argument<br>
|
||||||
|
int_lt First argument less than second argument <br>
|
||||||
|
int_lte First argument less than or equal to second argument<br>
|
||||||
|
int_eq First argument is numerically equal to the second argument<br>
|
||||||
|
int_ne First argument is not numerically equal to the second argument<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>gt, gte, lt, lte, eq, ne</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: Two integers to be
|
||||||
|
compared<br>
|
||||||
|
Returns: $(true) or $(false)<br>
|
||||||
|
<br>
|
||||||
|
gt First argument greater than second argument<br>
|
||||||
|
gte First argument greater than or equal to second argument<br>
|
||||||
|
lt First argument less than second argument <br>
|
||||||
|
lte First argument less than or equal to second argument<br>
|
||||||
|
eq First argument is numerically equal to the second argument<br>
|
||||||
|
ne First argument is not numerically equal to the second argument<br>
|
||||||
|
</span>
|
||||||
|
increment adds 1 to its argument, decrement subtracts 1. Note that<br>
|
||||||
|
decrement does not range check and hence will not underflow, but<br>
|
||||||
|
will incorrectly say that 0 - 1 = 0<br>
|
||||||
|
<hr><b>int_inc</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
Returns: The number incremented by 1 in x's
|
||||||
|
representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>inc</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
Returns: The argument incremented by 1<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_dec</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
Returns: The number decremented by 1 in x's
|
||||||
|
representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>dec</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
Returns: The argument decremented by 1<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_double</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
Returns: The number doubled (i.e. * 2) and returned in
|
||||||
|
x's representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>double</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
Returns: The integer times 2<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>int_halve</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A number in x's
|
||||||
|
representation<br>
|
||||||
|
Returns: The number halved (i.e. / 2) and returned in
|
||||||
|
x's representation<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>halve</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
Returns: The integer divided by 2<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>sequence</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
2: An integer<br>
|
||||||
|
Returns: The sequence [arg1 arg2] if arg1 >= arg2 or [arg2 arg1] if arg2 > arg1<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>dec2hex, dec2bin, dec2oct</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: An integer<br>
|
||||||
|
Returns: The decimal argument converted to hexadecimal, binary or octal<br>
|
||||||
|
</span>
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>Associative Arrays</h2>
|
||||||
|
An associate array maps a key value (a string with no spaces in it) to
|
||||||
|
a single value (any string). <br>
|
||||||
|
<b><br>
|
||||||
|
</b>
|
||||||
|
<hr style="width: 100%; height: 2px;"><b>set</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of associative
|
||||||
|
array<br>
|
||||||
|
2: The key
|
||||||
|
value to associate<br>
|
||||||
|
3: The
|
||||||
|
value associated with the key<br>
|
||||||
|
Returns: Nothing<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>get</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of associative
|
||||||
|
array<br>
|
||||||
|
2: The key
|
||||||
|
to retrieve<br>
|
||||||
|
Returns: The value stored in the array for that key<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>keys</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of associative
|
||||||
|
array<br>
|
||||||
|
Returns: Returns a list of all defined keys in the
|
||||||
|
array<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>defined</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of associative
|
||||||
|
array<br>
|
||||||
|
2: The key
|
||||||
|
to test<br>
|
||||||
|
Returns: Returns true if the key is defined (i.e. not
|
||||||
|
empty)<br>
|
||||||
|
</span>
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>Named Stacks</h2>
|
||||||
|
A stack is an ordered list of strings (with no spaces in them).<br>
|
||||||
|
<br>
|
||||||
|
<hr style="width: 100%; height: 2px;"><b>push</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
|
||||||
|
2: Value
|
||||||
|
to push onto the top of the stack (must not contain<br>
|
||||||
|
a space)<br>
|
||||||
|
Returns: None<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>pop</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
|
||||||
|
Returns: Top element from the stack after removing it<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>peek</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
|
||||||
|
Returns: Top element from the stack without removing it<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>depth</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of stack<br>
|
||||||
|
Returns: Number of items on the stack<br>
|
||||||
|
</span>
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>Function memoization</h2>
|
||||||
|
To reduce the number of calls to slow functions (such as $(shell) a single memoization function is provided.<br>
|
||||||
|
<br>
|
||||||
|
<hr style="width: 100%; height: 2px;"><b>memoize</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of function to memoize<br>
|
||||||
|
2: String argument for the function<br>
|
||||||
|
Returns: Result of $1 applied to $2 but only calls $1 once for each unique $2<br>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span>
|
||||||
|
<h2>Miscellaneous and Debugging Facilities</h2>
|
||||||
|
GMSL defines the following constants; all are accessed as normal GNU
|
||||||
|
Make variables by wrapping them in <span style="font-family: monospace;">$()</span> or <span style="font-family: monospace;">${}</span>.<br>
|
||||||
|
<br>
|
||||||
|
<table style="text-align: left;" border="1" cellpadding="2" cellspacing="2">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-style: italic;">Constant</span><br>
|
||||||
|
</td>
|
||||||
|
<td><span style="font-style: italic;">Value</span><br>
|
||||||
|
</td>
|
||||||
|
<td><span style="font-style: italic;">Purpose</span><br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-family: monospace;">true</span><br>
|
||||||
|
</td>
|
||||||
|
<td><span style="font-family: monospace;">T</span><br>
|
||||||
|
</td>
|
||||||
|
<td>Boolean for <span style="font-family: monospace;">$(if)</span>
|
||||||
|
and return from GMSL functions<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-family: monospace;">false</span><br>
|
||||||
|
</td>
|
||||||
|
<td><br>
|
||||||
|
</td>
|
||||||
|
<td>Boolean for <span style="font-family: monospace;">$(if)</span>
|
||||||
|
and return from GMSL functions<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-family: monospace;">gmsl_version</span><br>
|
||||||
|
</td>
|
||||||
|
<td><span style="font-family: monospace;">1 0 0</span><br>
|
||||||
|
</td>
|
||||||
|
<td>GMSL version number as list: major minor revision<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<span style="font-weight: bold;"><br>
|
||||||
|
gmsl_compatible</span><span style="font-family: monospace;"><br>
|
||||||
|
<br>
|
||||||
|
Arguments: List containing the desired library version number (maj min
|
||||||
|
rev)<br>
|
||||||
|
</span><span style="font-family: monospace;">Returns:
|
||||||
|
$(true) if this version of the library is compatible<br>
|
||||||
|
</span><span style="font-family: monospace;">
|
||||||
|
with the requested version number, otherwise $(false)</span>
|
||||||
|
<hr><b>gmsl-print-% (target not a function)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: The % should be
|
||||||
|
replaced by the name of a variable that you<br>
|
||||||
|
wish to
|
||||||
|
print out.<br>
|
||||||
|
Action: Echos the name of the variable that matches
|
||||||
|
the % and its value.<br>
|
||||||
|
For
|
||||||
|
example, 'make gmsl-print-SHELL' will output the value of<br>
|
||||||
|
the SHELL
|
||||||
|
variable<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>gmsl-echo-% (target not a function)</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: The % should be
|
||||||
|
replaced by the name of a variable that you<br>
|
||||||
|
wish to
|
||||||
|
print out.<br>
|
||||||
|
Action: Echos the value of the variable that matches
|
||||||
|
the %.<br>
|
||||||
|
For
|
||||||
|
example, 'make gmsl-echo-SHELL' will output the value of<br>
|
||||||
|
the SHELL
|
||||||
|
variable<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>assert</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: A boolean that must
|
||||||
|
be true or the assertion will fail<br>
|
||||||
|
2: The
|
||||||
|
message to print with the assertion<br>
|
||||||
|
Returns: None<br>
|
||||||
|
</span>
|
||||||
|
<hr><b>assert_exists</b><br>
|
||||||
|
<br>
|
||||||
|
<span style="font-family: monospace;">Arguments: 1: Name of file that
|
||||||
|
must exist, if it is missing an assertion<br>
|
||||||
|
will be
|
||||||
|
generated<br>
|
||||||
|
Returns: None<br>
|
||||||
|
</span>
|
||||||
|
<hr style="width: 100%; height: 2px;"><br>
|
||||||
|
GMSL has a number of environment variables (or command-line overrides)
|
||||||
|
that control various bits of functionality:<br>
|
||||||
|
<br>
|
||||||
|
<table style="text-align: left;" border="1" cellpadding="2" cellspacing="2">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-style: italic;">Variable</span><br>
|
||||||
|
</td>
|
||||||
|
<td><span style="font-style: italic;">Purpose</span><br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-family: monospace;">GMSL_NO_WARNINGS</span><br>
|
||||||
|
</td>
|
||||||
|
<td>If set prevents GMSL from outputting warning messages:
|
||||||
|
artithmetic functions generate underflow warnings.<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-family: monospace;">GMSL_NO_ERRORS</span><br>
|
||||||
|
</td>
|
||||||
|
<td>If set prevents GMSL from generating fatal errors: division
|
||||||
|
by zero or failed assertions are fatal.<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span style="font-family: monospace;">GMSL_TRACE</span><br>
|
||||||
|
</td>
|
||||||
|
<td>Enables function tracing. Calls to GMSL functions will
|
||||||
|
result in name and arguments being traced.<br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<span style="font-family: monospace;"></span><br>
|
||||||
|
<hr>
|
||||||
|
Copyright (c) 2005-2022 <a href="https://www.jgc.org/">John Graham-Cumming</a>.<br>
|
||||||
|
<hr style="width: 100%; height: 2px;">
|
||||||
|
</body></html>
|
|
@ -12,3 +12,9 @@ BUILD_VERSION?=$(shell git describe --tags)
|
||||||
BUILD_TIMESTAMP=$(shell date +%F"_"%T)
|
BUILD_TIMESTAMP=$(shell date +%F"_"%T)
|
||||||
DEFAULT_CONFIGDIR?=/etc/crowdsec
|
DEFAULT_CONFIGDIR?=/etc/crowdsec
|
||||||
DEFAULT_DATADIR?=/var/lib/crowdsec/data
|
DEFAULT_DATADIR?=/var/lib/crowdsec/data
|
||||||
|
|
||||||
|
PKG_CONFIG:=$(shell command -v pkg-config 2>/dev/null)
|
||||||
|
|
||||||
|
# See if we have libre2-dev installed for C++ optimizations.
|
||||||
|
# In fedora and other distros, we need to tell where to find re2.pc
|
||||||
|
RE2_CHECK := $(shell PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$(PKG_CONFIG_PATH) pkg-config --libs re2 2>/dev/null)
|
||||||
|
|
|
@ -6,7 +6,7 @@ PREFIX=$(shell $$env:TEMP)
|
||||||
|
|
||||||
# Current versioning information from env
|
# Current versioning information from env
|
||||||
# BUILD_VERSION?=$(shell (Invoke-WebRequest -UseBasicParsing -Uri https://api.github.com/repos/crowdsecurity/crowdsec/releases/latest).Content | jq -r '.tag_name')
|
# BUILD_VERSION?=$(shell (Invoke-WebRequest -UseBasicParsing -Uri https://api.github.com/repos/crowdsecurity/crowdsec/releases/latest).Content | jq -r '.tag_name')
|
||||||
#hardcode it till i find a workaround
|
# hardcode it till I find a workaround
|
||||||
BUILD_VERSION?=$(shell git describe --tags $$(git rev-list --tags --max-count=1))
|
BUILD_VERSION?=$(shell git describe --tags $$(git rev-list --tags --max-count=1))
|
||||||
BUILD_TIMESTAMP?=$(shell Get-Date -Format "yyyy-MM-dd_HH:mm:ss")
|
BUILD_TIMESTAMP?=$(shell Get-Date -Format "yyyy-MM-dd_HH:mm:ss")
|
||||||
DEFAULT_CONFIGDIR?=C:\\ProgramData\\CrowdSec\\config
|
DEFAULT_CONFIGDIR?=C:\\ProgramData\\CrowdSec\\config
|
||||||
|
@ -18,3 +18,5 @@ CP=Copy-Item
|
||||||
CPR=Copy-Item -Recurse
|
CPR=Copy-Item -Recurse
|
||||||
MKDIR=New-Item -ItemType directory
|
MKDIR=New-Item -ItemType directory
|
||||||
WIN_IGNORE_ERR=; exit 0
|
WIN_IGNORE_ERR=; exit 0
|
||||||
|
|
||||||
|
PKG_CONFIG:=$(shell Get-Command pkg-config -ErrorAction SilentlyContinue)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/jarcoal/httpmock"
|
"github.com/jarcoal/httpmock"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDownladFile(t *testing.T) {
|
func TestDownloadFile(t *testing.T) {
|
||||||
examplePath := "./example.txt"
|
examplePath := "./example.txt"
|
||||||
defer os.Remove(examplePath)
|
defer os.Remove(examplePath)
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,12 @@
|
||||||
- crowdsecurity.testing.go
|
- crowdsecurity.testing.go
|
||||||
- crowdsecurity.testing.machine_id
|
- crowdsecurity.testing.machine_id
|
||||||
- crowdsecurity.testing.epel
|
- crowdsecurity.testing.epel
|
||||||
|
- crowdsecurity.testing.powertools
|
||||||
- crowdsecurity.testing.git
|
- crowdsecurity.testing.git
|
||||||
- crowdsecurity.testing.gcc
|
- crowdsecurity.testing.gcc
|
||||||
- crowdsecurity.testing.gnu_make
|
- crowdsecurity.testing.gnu_make
|
||||||
|
- crowdsecurity.testing.pkg_config
|
||||||
|
- crowdsecurity.testing.re2
|
||||||
- crowdsecurity.testing.bats_requirements
|
- crowdsecurity.testing.bats_requirements
|
||||||
|
|
||||||
- name: "Install Postgres"
|
- name: "Install Postgres"
|
||||||
|
|
|
@ -9,13 +9,13 @@ roles:
|
||||||
# these should be included as dependencies of crowdsecurity.testing, but sometime are not
|
# these should be included as dependencies of crowdsecurity.testing, but sometime are not
|
||||||
- src: geerlingguy.repo-epel
|
- src: geerlingguy.repo-epel
|
||||||
- src: gantsign.golang
|
- src: gantsign.golang
|
||||||
|
- src: robertdebock.powertools
|
||||||
|
|
||||||
collections:
|
collections:
|
||||||
- name: https://github.com/crowdsecurity/ansible-collection-crowdsecurity.testing.git
|
- name: https://github.com/crowdsecurity/ansible-collection-crowdsecurity.testing.git
|
||||||
type: git
|
type: git
|
||||||
version: main
|
version: v0.0.3
|
||||||
|
|
||||||
# - name: crowdsecurity.testing
|
# - name: crowdsecurity.testing
|
||||||
# source: ../../../crowdsecurity.testing
|
# source: ../../../crowdsecurity.testing
|
||||||
# type: dir
|
# type: dir
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,13 @@
|
||||||
# vim: set ft=yaml.ansible:
|
# vim: set ft=yaml.ansible:
|
||||||
---
|
---
|
||||||
- name: "Set make_cmd = make (!bsd)"
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
make_cmd: make
|
|
||||||
when:
|
|
||||||
- ansible_facts.system not in ['FreeBSD', 'OpenBSD']
|
|
||||||
|
|
||||||
- name: "Set make_cmd = gmake (bsd)"
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
make_cmd: gmake
|
|
||||||
when:
|
|
||||||
- ansible_facts.system in ['FreeBSD', 'OpenBSD']
|
|
||||||
|
|
||||||
- name: "Build crowdsec from sources, prepare test environment and fixture"
|
- name: "Build crowdsec from sources, prepare test environment and fixture"
|
||||||
become: false
|
become: false
|
||||||
block:
|
block:
|
||||||
- name: "Make bats-build bats-fixture"
|
- name: "Make bats-build bats-fixture"
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: "{{ make_cmd }} bats-build bats-fixture"
|
# static build and we don't have to mess with LD_LIBRARY_PATH
|
||||||
|
cmd: "{{ make_cmd }} bats-build bats-fixture BUILD_STATIC=1"
|
||||||
chdir: "{{ ansible_env.HOME }}/crowdsec"
|
chdir: "{{ ansible_env.HOME }}/crowdsec"
|
||||||
creates: "{{ ansible_env.HOME }}/crowdsec/test/local-init/init-config-data.tar"
|
creates: "{{ ansible_env.HOME }}/crowdsec/test/local-init/init-config-data.tar"
|
||||||
environment:
|
environment:
|
||||||
|
|
1
test/ansible/vagrant/alma-8/Vagrantfile
vendored
1
test/ansible/vagrant/alma-8/Vagrantfile
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'generic/alma8'
|
config.vm.box = 'generic/alma8'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
5
test/ansible/vagrant/alma-8/bootstrap
Executable file
5
test/ansible/vagrant/alma-8/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
unset IFS
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
sudo dnf -y install kitty-terminfo
|
1
test/ansible/vagrant/alma-9/Vagrantfile
vendored
1
test/ansible/vagrant/alma-9/Vagrantfile
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'generic/alma9'
|
config.vm.box = 'generic/alma9'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
5
test/ansible/vagrant/alma-9/bootstrap
Executable file
5
test/ansible/vagrant/alma-9/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
unset IFS
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
sudo dnf -y install kitty-terminfo
|
3
test/ansible/vagrant/centos-8/Vagrantfile
vendored
3
test/ansible/vagrant/centos-8/Vagrantfile
vendored
|
@ -1,7 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'centos/stream8'
|
config.vm.box = 'generic/centos8s'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
6
test/ansible/vagrant/centos-8/bootstrap
Executable file
6
test/ansible/vagrant/centos-8/bootstrap
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
unset IFS
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
sudo dnf -y install dnf-plugins-core
|
||||||
|
dnf config-manager --set-enabled powertools
|
1
test/ansible/vagrant/centos-9/Vagrantfile
vendored
1
test/ansible/vagrant/centos-9/Vagrantfile
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'generic/centos9s'
|
config.vm.box = 'generic/centos9s'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
6
test/ansible/vagrant/centos-9/bootstrap
Executable file
6
test/ansible/vagrant/centos-9/bootstrap
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
unset IFS
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
sudo dnf -y install dnf-plugins-core
|
||||||
|
dnf config-manager --set-enabled crb
|
1
test/ansible/vagrant/fedora-37/Vagrantfile
vendored
1
test/ansible/vagrant/fedora-37/Vagrantfile
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'generic/fedora37'
|
config.vm.box = 'generic/fedora37'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
5
test/ansible/vagrant/fedora-37/bootstrap
Executable file
5
test/ansible/vagrant/fedora-37/bootstrap
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
unset IFS
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
sudo dnf -y install kitty-terminfo
|
1
test/ansible/vagrant/freebsd-12/Vagrantfile
vendored
1
test/ansible/vagrant/freebsd-12/Vagrantfile
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'generic/freebsd12'
|
config.vm.box = 'generic/freebsd12'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
6
test/ansible/vagrant/freebsd-12/bootstrap
Normal file
6
test/ansible/vagrant/freebsd-12/bootstrap
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
pkg install -y gtar
|
||||||
|
|
1
test/ansible/vagrant/freebsd-13/Vagrantfile
vendored
1
test/ansible/vagrant/freebsd-13/Vagrantfile
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
config.vm.box = 'generic/freebsd13'
|
config.vm.box = 'generic/freebsd13'
|
||||||
|
config.vm.provision 'shell', path: 'bootstrap'
|
||||||
end
|
end
|
||||||
|
|
||||||
common = '../common'
|
common = '../common'
|
||||||
|
|
6
test/ansible/vagrant/freebsd-13/bootstrap
Normal file
6
test/ansible/vagrant/freebsd-13/bootstrap
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
pkg install -y gtar
|
||||||
|
|
5
test/ansible/vagrant/ubuntu-20.04-focal/bootstrap
Normal file
5
test/ansible/vagrant/ubuntu-20.04-focal/bootstrap
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
unset IFS
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
sudo apt install -y kitty-terminfo
|
|
@ -10,7 +10,7 @@ ifdef PACKAGE_TESTING
|
||||||
INIT_BACKEND = systemd
|
INIT_BACKEND = systemd
|
||||||
CONFIG_BACKEND = global
|
CONFIG_BACKEND = global
|
||||||
else
|
else
|
||||||
# LOCAL_DIR will contain contains a local instance of crowdsec, complete with
|
# LOCAL_DIR contains a local instance of crowdsec, complete with
|
||||||
# configuration and data
|
# configuration and data
|
||||||
LOCAL_DIR = $(TEST_DIR)/local
|
LOCAL_DIR = $(TEST_DIR)/local
|
||||||
BIN_DIR = $(LOCAL_DIR)/bin
|
BIN_DIR = $(LOCAL_DIR)/bin
|
||||||
|
|
|
@ -101,9 +101,9 @@ teardown() {
|
||||||
# check that LAPI configuration is loaded (human and json, not shows in raw)
|
# check that LAPI configuration is loaded (human and json, not shows in raw)
|
||||||
|
|
||||||
rune -0 cscli config show -o human
|
rune -0 cscli config show -o human
|
||||||
assert_line --regexp ".*- URL\s+: http://127.0.0.1:8080/"
|
assert_line --regexp ".*- URL +: http://127.0.0.1:8080/"
|
||||||
assert_line --regexp ".*- Login\s+: githubciXXXXXXXXXXXXXXXXXXXXXXXX"
|
assert_line --regexp ".*- Login +: githubciXXXXXXXXXXXXXXXXXXXXXXXX"
|
||||||
assert_line --regexp ".*- Credentials File\s+: .*/local_api_credentials.yaml"
|
assert_line --regexp ".*- Credentials File +: .*/local_api_credentials.yaml"
|
||||||
|
|
||||||
rune -0 cscli config show -o json
|
rune -0 cscli config show -o json
|
||||||
rune -0 jq -c '.API.Client.Credentials | [.url,.login]' <(output)
|
rune -0 jq -c '.API.Client.Credentials | [.url,.login]' <(output)
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
is_crowdsec_running() {
|
is_crowdsec_running() {
|
||||||
|
case $(uname) in
|
||||||
|
"Linux")
|
||||||
# ignore processes in containers
|
# ignore processes in containers
|
||||||
PIDS=$(pgrep --ns $$ -x 'crowdsec')
|
PIDS=$(pgrep --ns $$ -x 'crowdsec')
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
PIDS=$(pgrep -x 'crowdsec')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# The process can be slow, especially on CI and during test coverage.
|
# The process can be slow, especially on CI and during test coverage.
|
||||||
|
|
Loading…
Reference in a new issue