Skip to content

Commit

Permalink
Add Fedora integration` test
Browse files Browse the repository at this point in the history
- add minimial nsterm example which reflects the
  issue with `top`

Ref: criblio#1567
  • Loading branch information
michalbiesek committed Jul 4, 2023
1 parent 25f900a commit 850da8f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,15 @@ services:
dockerfile: ./cli_rules/Dockerfile
<<: *scope-common

fedora:
image: ghcr.io/criblio/appscope-test-fedora:${TAG:?Missing TAG environment variable}
build:
cache_from:
- ghcr.io/criblio/appscope-test-fedora:${TAG:?Missing TAG environment variable}
context: .
dockerfile: ./fedora/Dockerfile
<<: *scope-common

sshd:
image: ghcr.io/criblio/appscope-test-sshd:${TAG:?Missing TAG environment variable}
build:
Expand Down
27 changes: 27 additions & 0 deletions test/integration/fedora/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM fedora:39

RUN dnf update -y && dnf install -y \
gcc \
ncurses-devel \
&& dnf clean all

ENV PATH="/usr/local/scope:/usr/local/scope/bin:${PATH}"
COPY scope-profile.sh /etc/profile.d/scope.sh
COPY gdbinit /root/.gdbinit

RUN mkdir /opt/test
COPY ./fedora/nsterm.c /opt/test/nsterm.c
RUN gcc -g -o /opt/test/nsterm /opt/test/nsterm.c -lncurses

RUN mkdir /usr/local/scope && \
mkdir /usr/local/scope/bin && \
mkdir /usr/local/scope/lib && \
mkdir -p /opt/test-runner/logs/ && \
ln -s /opt/appscope/bin/linux/$(uname -m)/scope /usr/local/scope/bin/scope && \
ln -s /opt/appscope/lib/linux/$(uname -m)/libscope.so /usr/local/scope/lib/libscope.so

COPY fedora/scope-test /usr/local/scope/scope-test

COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["test"]
12 changes: 12 additions & 0 deletions test/integration/fedora/nsterm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define _GNU_SOURCE
#include <curses.h>
#include <term.h>

int
main(int argc, char *argv[])
{
int res = setupterm((char *)0, 1, (int *)0);

printf("setupterm res %d\n", res);
return 0;
}
58 changes: 58 additions & 0 deletions test/integration/fedora/scope-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#! /bin/bash
DEBUG=0 # set this to 1 to capture the EVT_FILE for each test

FAILED_TEST_LIST=""
FAILED_TEST_COUNT=0

starttest(){
CURRENT_TEST=$1
echo "==============================================="
echo " Testing $CURRENT_TEST "
echo "==============================================="
ERR=0
}

evaltest(){
echo " Evaluating $CURRENT_TEST"
}

endtest(){
if [ $ERR -eq "0" ]; then
RESULT=PASSED
else
RESULT=FAILED
FAILED_TEST_LIST+=$CURRENT_TEST
FAILED_TEST_LIST+=" "
FAILED_TEST_COUNT=$(($FAILED_TEST_COUNT + 1))
fi

echo "*************** $CURRENT_TEST $RESULT ***************"
echo ""
echo ""
}


starttest nsterm_test

cd /opt/test/
scope run -- ./nsterm
if [ $? -ne 0 ]; then
ERR+=1
fi

endtest

if (( $FAILED_TEST_COUNT == 0 )); then
echo ""
echo ""
echo "*************** ALL TESTS PASSED ***************"
else
echo "*************** SOME TESTS FAILED ***************"
echo "Failed tests: $FAILED_TEST_LIST"
echo "Refer to these files for more info:"
for FAILED_TEST in $FAILED_TEST_LIST; do
echo " $EVT_FILE.$FAILED_TEST"
done
fi

exit ${FAILED_TEST_COUNT}

0 comments on commit 850da8f

Please sign in to comment.