initial gating tests for rhel10

JIRA: https://issues.redhat.com/browse/RHELMISC-3943

Signed-off-by: Jianwen Ji <jiji@redhat.com>
This commit is contained in:
Jianwen Ji 2024-05-10 22:07:09 +08:00
parent cadcc713bd
commit 09ab0adc95
12 changed files with 271 additions and 0 deletions

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

22
tests/run-test.sh Normal file
View File

@ -0,0 +1,22 @@
#!/bin/bash
_UID=`id -u`
if [ $_UID -ne 0 ]
then
echo "Run this test as root"
exit 1
fi
gcc test.c -o test
#
# XXX: module auto-load not support by nfnetlink_cttimeout yet :-(
#
# any or all of these might be built-ins rather than modules, so don't error
# out on failure from modprobe
modprobe nf_conntrack_ipv4 || true
modprobe nf_conntrack_ipv6 || true
modprobe nf_conntrack_proto_udplite || true
modprobe nf_conntrack_proto_sctp || true
modprobe nf_conntrack_proto_dccp || true
modprobe nf_conntrack_proto_gre || true
./test timeout

100
tests/test.c Normal file
View File

@ -0,0 +1,100 @@
/*
* (c) 2012 by Pablo Neira Ayuso <pablo@netfilter.org>
*
* Extremely simple test utility for the command line tools.
*
* Based on test-conntrack.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
#define PATH "/usr/sbin"
int main(int argc, char *argv[])
{
int ret, ok = 0, bad = 0, line;
FILE *fp;
DIR *d;
char buf[1024];
struct dirent *dent;
char file[1024];
if (argc < 2) {
fprintf(stderr, "Usage: %s directory\n", argv[0]);
exit(EXIT_FAILURE);
}
d = opendir(argv[1]);
if (d == NULL) {
perror("opendir");
exit(EXIT_FAILURE);
}
setenv("PATH", PATH, 1);
while ((dent = readdir(d)) != NULL) {
sprintf(file, "%s/%s", argv[1], dent->d_name);
line = 0;
fp = fopen(file, "r");
if (fp == NULL) {
perror("cannot find testsuite file");
exit(EXIT_FAILURE);
}
while (fgets(buf, sizeof(buf), fp)) {
char *res;
line++;
if (buf[0] == '#' || buf[0] == ' ')
continue;
res = strchr(buf, ';');
if (!res) {
printf("malformed file %s at line %d\n",
dent->d_name, line);
exit(EXIT_FAILURE);
}
*res = '\0';
res+=2;
printf("(%d) Executing: %s\n", line, buf);
ret = system(buf);
if (WIFEXITED(ret) &&
WEXITSTATUS(ret) == EXIT_SUCCESS) {
if (res[0] == 'O' &&
res[1] == 'K')
ok++;
else {
bad++;
printf("^----- BAD\n");
}
} else {
if (res[0] == 'B' &&
res[1] == 'A' &&
res[2] == 'D')
ok++;
else {
bad++;
printf("^----- BAD\n");
}
}
printf("=====\n");
}
fclose(fp);
}
closedir(d);
fprintf(stdout, "OK: %d BAD: %d\n", ok, bad);
}

15
tests/tests.yml Normal file
View File

@ -0,0 +1,15 @@
# Tests for libnetfilter_cttimeout
- hosts: localhost
tags:
- classic
roles:
- role: standard-test-basic
required_packages:
- gcc
- conntrack-tools
tests:
- sanity-test:
dir: .
run: bash ./run-test.sh timeout | tee cttimeout_test.log | grep -q '^OK':' [0-9]* BAD':' 0$'
save_files:
- cttimeout_test.log

16
tests/timeout/00tcp Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet tcp established 100 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet tcp syn_sent 1 syn_recv 2 established 3 fin_wait 4 close_wait 5 last_ack 6 time_wait 7 close 8 syn_sent2 9 retrans 10 unacknowledged 11 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/01udp Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet udp unreplied 10 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet udp unreplied 1 replied 2 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/02generic Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet generic timeout 10 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet generic timeout 1 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/03udplite Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet udplite unreplied 10 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet udplite unreplied 1 replied 2 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/04icmp Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet icmp timeout 10 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet icmp timeout 1 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/05icmpv6 Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet6 icmpv6 timeout 10 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet6 icmpv6 timeout 1 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/06sctp Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet sctp established 100 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet sctp closed 1 cookie_wait 2 cookie_echoed 3 established 4 shutdown_sent 5 shutdown_recd 6 shutdown_ack_sent 7 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK

16
tests/timeout/08gre Normal file
View File

@ -0,0 +1,16 @@
# add policy object `test'
nfct add timeout test inet gre unreplied 10 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK
# get unexistent policy object `dummy'
nfct get timeout test ; BAD
# delete policy object `test', however, it does not exists anymore
nfct delete timeout test ; BAD
# add policy object `test'
nfct add timeout test inet gre unreplied 1 replied 2 ; OK
# get policy object `test'
nfct get timeout test ; OK
# delete policy object `test'
nfct delete timeout test ; OK