Skip to content

Commit

Permalink
add a standalone_simple contrib example
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Jaburek <[email protected]>
  • Loading branch information
comps committed Jun 22, 2022
1 parent e1a6796 commit ab100c4
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 22 deletions.
21 changes: 2 additions & 19 deletions examples/contrib/standalone/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
SHELL := /bin/bash

which = $(shell x=$$(command -v $(1) 2>/dev/null); \
[ "$${x::1}" = "/" ] && echo "$$x")

DNF := $(call which,dnf)
ifeq ($(DNF),)
DNF := $(call which,yum)
endif

PTEF_URL := https://github.com/comps/ptef/archive/refs/heads/main.tar.gz


.PHONY: all deps ptef c clean
all: deps ptef c

ifeq ($(shell id -u), 0)
deps:
$(DNF) -y install gcc make python3 bash bash-devel curl
else
deps: ;
endif
.PHONY: all c clean
all: ptef c

ptef:
mkdir ptef-build && ( \
Expand Down
6 changes: 5 additions & 1 deletion examples/contrib/standalone/README
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ This allows the suite to build and run unprivileged, though it does require some
package dependencies to be provided by the OS, more than would be required for
installing PTEF as a binary package.

Do 'make' prior to running.
Do ie.

dnf install gcc make python3 bash bash-devel curl

prior to issuing 'make' and './run'.

To run tests from inside the hierarchy manually (rather than running the full
suite), source the 'run' in top level first (from a bash shell).
Expand Down
4 changes: 2 additions & 2 deletions examples/contrib/standalone/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

export PATH="$PATH:$PWD/ptef/usr/bin"
export PATH="$PWD/ptef/usr/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/ptef/usr/lib64"
export LIBPTEF_BASH="$PWD/ptef/usr/lib64/libptef-bash.so"
export BASHLIB="$PWD/ptef/usr/share/ptef/builtins.bash"
Expand All @@ -11,4 +11,4 @@ export PYTHONPATH="$PYTHONPATH:$site_packages"
return 2>/dev/null

base=$(basename "$0")
./ptef/usr/bin/ptef-runner -a "$base" "$@"
ptef-runner -a "$base" "$@"
2 changes: 2 additions & 0 deletions examples/contrib/standalone_simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
c/run
ptef
17 changes: 17 additions & 0 deletions examples/contrib/standalone_simple/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SHELL := /bin/bash
PTEF_URL := https://github.com/comps/ptef/archive/refs/heads/main.tar.gz

.PHONY: all clean
all: ptef

ptef:
mkdir ptef-build && ( \
cd ptef-build && \
curl -kL "$(PTEF_URL)" | tar -xvz --strip-components=1 && \
make && \
make install DESTDIR="$(PWD)/ptef" \
)
rm -rf ptef-build

clean:
rm -rf ptef-build ptef
19 changes: 19 additions & 0 deletions examples/contrib/standalone_simple/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This shows how to make a test suite building its own PTEF binaries, independent
of anything provided by the OS.

This is a CLI-only trivial version of the 'standalone' example - see that one
if you need full C / bash / python API support.

The advantage of this version is that it has very minimal build dependencies
- basically just a C compiler and GNU Make, that's it. If all you care about
is running ptef-* CLI commands from shell-based tests, that's all you need.

Do ie.

dnf install gcc make curl

prior to issuing 'make' and './run'.

To run tests from inside the hierarchy manually (rather than running the full
suite), source the 'run' in top level first (from a bash shell).
This will export some env variables into your current shell.
7 changes: 7 additions & 0 deletions examples/contrib/standalone_simple/cli/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# this could be any shell

ptef-report TESTME "from-inside"

exit 0
9 changes: 9 additions & 0 deletions examples/contrib/standalone_simple/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

export PATH="$PWD/ptef/usr/bin:$PATH"

# if sourcing, exit now
return 2>/dev/null

base=$(basename "$0")
ptef-runner -a "$base" "$@"
1 change: 1 addition & 0 deletions examples/contrib/standalone_simple/symlink/run
3 changes: 3 additions & 0 deletions examples/contrib/standalone_simple/symlink/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo foo bar >&2
exit 0

0 comments on commit ab100c4

Please sign in to comment.