~apparmor-dev/apparmor/master

« back to all changes in this revision

Viewing changes to parser/unit_test.h

  • Committer: Steve Beattie
  • Date: 2019-02-19 09:38:13 UTC
  • Revision ID: sbeattie@ubuntu.com-20190219093813-ud526ee6hwn8nljz
The AppArmor project has been converted to git and is now hosted on
gitlab.

To get the converted repository, please do
  git clone https://gitlab.com/apparmor/apparmor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *   Copyright (c) 2013
3
 
 *   Canonical Ltd. (All rights reserved)
4
 
 *
5
 
 *   This program is free software; you can redistribute it and/or
6
 
 *   modify it under the terms of version 2 of the GNU General Public
7
 
 *   License published by the Free Software Foundation.
8
 
 *
9
 
 *   This program is distributed in the hope that it will be useful,
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *   GNU General Public License for more details.
13
 
 *
14
 
 *   You should have received a copy of the GNU General Public License
15
 
 *   along with this program; if not, contact Novell, Inc. or Canonical
16
 
 *   Ltd.
17
 
 */
18
 
#ifndef __AA_UNIT_TEST_H
19
 
#define __AA_UNIT_TEST_H
20
 
 
21
 
#ifdef UNIT_TEST
22
 
/* For the unit-test builds, we must include function stubs for stuff that
23
 
 * only exists in the excluded object files; everything else should live
24
 
 * in parser_common.c.
25
 
 */
26
 
 
27
 
#include <stdarg.h>
28
 
#include <stdlib.h>
29
 
#include <linux/limits.h>
30
 
 
31
 
#undef _
32
 
#define _(s) (s)
33
 
 
34
 
/* parser_yacc.y */
35
 
void yyerror(const char *msg, ...)
36
 
{
37
 
        va_list arg;
38
 
        char buf[PATH_MAX];
39
 
 
40
 
        va_start(arg, msg);
41
 
        vsnprintf(buf, sizeof(buf), msg, arg);
42
 
        va_end(arg);
43
 
 
44
 
        PERROR(_("AppArmor parser error: %s\n"), buf);
45
 
 
46
 
        exit(1);
47
 
}
48
 
 
49
 
#define MY_TEST(statement, error)               \
50
 
        if (!(statement)) {                     \
51
 
                PERROR("FAIL: %s\n", error);    \
52
 
                rc = 1;                         \
53
 
        }
54
 
 
55
 
#endif /* UNIT_TEST */
56
 
 
57
 
#endif /* __AA_UNIT_TEST_H */