summaryrefslogtreecommitdiffstats
path: root/debian/tests/build-with-static-libsystemd
blob: 6b91009a6bf8c6422a3c64c9b1014e6491357948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
# autopkgtest check: Test build against static libsystemd

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > uuid-gen.c
#include <assert.h>
#include <stdio.h>

#include <systemd/sd-id128.h>

int main(void)
{
        sd_id128_t id;
        char id_str[SD_ID128_STRING_MAX];
        int r;

        r = sd_id128_randomize(&id);
        if (r < 0) {
                fprintf(stderr, "Failed to generate id: %s\n", strerror(-r));
                return 1;
        }

        assert(sd_id128_to_string(id, id_str) > 0);
        printf("uuid: %s\n", id_str);

        return 0;
}
EOF

gcc -Wall -Werror -o uuid-gen uuid-gen.c -l:libsystemd.a -lcap
echo "build: OK"
[ -x uuid-gen ]
./uuid-gen
echo "run: OK"