File: action-unit-action.c

package info (click to toggle)
snoopy 2.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,016 kB
  • sloc: ansic: 7,169; sh: 4,514; makefile: 1,095
file content (88 lines) | stat: -rw-r--r-- 2,555 bytes parent folder | download | duplicates (3)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * SNOOPY COMMAND LOGGER
 *
 * Copyright (c) 2022 Bostjan Skufca Jese <bostjan@a2o.si>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */



/*
 * Includes order: from local to global
 */
#include "snoopy.h"

#include "action-common.h"

#include "action-unit-action-log-message-dispatch.h"
#include "action-unit-action-log-syscall-exec.h"

#include <stdio.h>
#include <string.h>



void snoopyTestCli_action_unit_action_showHelp ()
{
    char * helpContent =
        "Snoopy TEST SUITE CLI utility :: Action `unit` :: Unit `action`\n"
        "\n"
        "Usage:\n"
        "    snoopy-test unit action SUBUNIT [ARGS]\n"
        "\n"
        "Available subunits:\n"
        "    log-message-dispatch,lmd   Run a unit test on src/action/log-message-dispatch.c\n"
        "    log-syscall-exec,lse       Run a unit test on src/action/log-syscall-exec.c\n"
        "\n"
        "    --help,-h          Show this help\n"
        "    UNIT --help        Show UNIT's help\n"
        "\n";

    printf("%s", helpContent);
}



int snoopyTestCli_action_unit_action (int argc, char ** argv)
{
    const char * subunit;

    if (argc < 1) {
        snoopyTestCli_action_unit_action_showHelp();
        fatalError("No subunit specified.");
    }
    subunit = argv[0];


    if ((0 == strcmp(subunit, "log-message-dispatch")) || (0 == strcmp(subunit, "lmd"))) {
        return snoopyTestCli_action_unit_action_log_message_dispatch(argc-1, &argv[1]);
    }

    if ((0 == strcmp(subunit, "log-syscall-exec")) || (0 == strcmp(subunit, "lse"))) {
        return snoopyTestCli_action_unit_action_log_syscall_exec(argc-1, &argv[1]);
    }


    if ((0 == strcmp(subunit, "--help")) || (0 == strcmp(subunit, "-h"))) {
        snoopyTestCli_action_unit_action_showHelp();
        return 0;
    }


    snoopyTestCli_action_unit_action_showHelp();
    fatalErrorValue("Unknown subunit", subunit);
    return 127;
}