| 1 |
#!/bin/sh |
| 2 |
# autopkgtest check: Build and run a program against net-snmp agent library |
| 3 |
# Checking headers and net-snmp-config file are installed correctly |
| 4 |
|
| 5 |
set -e |
| 6 |
|
| 7 |
WORKDIR=$(mktemp -d) |
| 8 |
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM |
| 9 |
cd $WORKDIR |
| 10 |
cat <<EOF > agent-test.c |
| 11 |
|
| 12 |
#include <net-snmp/net-snmp-config.h> |
| 13 |
#include <net-snmp/net-snmp-includes.h> |
| 14 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 15 |
#include <assert.h> |
| 16 |
|
| 17 |
int main(int argc, char *argv[]) |
| 18 |
{ |
| 19 |
netsnmp_session session, *ss; |
| 20 |
|
| 21 |
assert(2 == snmp_parse_args(argc, argv, &session, NULL, NULL)); |
| 22 |
assert(NULL != (ss = snmp_open(&session))); |
| 23 |
assert(0 < netsnmp_get_agent_uptime()); |
| 24 |
netsnmp_cleanup_session(&session); |
| 25 |
return 0; |
| 26 |
} |
| 27 |
EOF |
| 28 |
|
| 29 |
gcc -o agent-test agent-test.c `net-snmp-config --agent-libs` |
| 30 |
echo "build: OK" |
| 31 |
[ -x agent-test ] |
| 32 |
./agent-test localhost |
| 33 |
echo "run: OK" |