@@ -16,7 +16,16 @@ BEGIN {
$v = " ";
}
- plan tests => 2;
+ $result = system "runcon -t test_watchkey_t $basedir/watchkey $v -c";
+
+ # check if O_NOTIFICATION_PIPE is supported - ENOPKG
+ if ( $result >> 8 eq 65 ) {
+ plan skip_all =>
+"pipe2(2) does not support O_NOTIFICATION_PIPE; CONFIG_WATCH_QUEUE probably not set";
+ }
+ else {
+ plan tests => 2;
+ }
}
$result = system "runcon -t test_watchkey_t $basedir/watchkey $v";
@@ -27,8 +27,9 @@ static long keyctl_watch_key(int key, int watch_fd, int watch_id)
static void print_usage(char *progname)
{
fprintf(stderr,
- "usage: %s [-v]\n"
+ "usage: %s [-cv]\n"
"Where:\n\t"
+ "-c Check for availability.\n"
"-v Print information.\n", progname);
exit(-1);
}
@@ -37,10 +38,14 @@ int main(int argc, char **argv)
{
int opt, fd, pipefd[2], result, save_errno;
char *context;
+ bool check = false;
bool verbose = false;
- while ((opt = getopt(argc, argv, "v")) != -1) {
+ while ((opt = getopt(argc, argv, "cv")) != -1) {
switch (opt) {
+ case 'c':
+ check = true;
+ break;
case 'v':
verbose = true;
break;
@@ -60,6 +65,13 @@ int main(int argc, char **argv)
free(context);
}
+ if (check) {
+ result = pipe2(pipefd, O_NOTIFICATION_PIPE);
+ if (!result || errno != ENOPKG)
+ exit(0);
+ exit(ENOPKG);
+ }
+
result = pipe2(pipefd, O_NOTIFICATION_PIPE);
if (result < 0) {
fprintf(stderr, "Failed to create pipe2(2): %s\n",
Debian does not set CONFIG_WATCH_QUEUE, whereby pipe2(2) returns ENOPKG for the option O_NOTIFICATION_PIPE. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> --- v2: return ENOPKG when availability check fails --- tests/watchkey/test | 11 ++++++++++- tests/watchkey/watchkey.c | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-)