File: action-run-everything.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 (127 lines) | stat: -rw-r--r-- 3,569 bytes parent folder | download | duplicates (2)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * SNOOPY COMMAND LOGGER
 *
 * Copyright (c) 2015 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 "action-common.h"

#include "action-run-datasource.h"
#include "action-run-filter.h"
#include "action-run-output.h"

#include "snoopy.h"
#include "entrypoint/test-cli.h"

#include "configuration.h"
#ifdef SNOOPY_FILTERING_ENABLED
#include "filtering.h"
#endif
#include "inputdatastorage.h"
#include "action/log-message-dispatch.h"
#include "message.h"

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






void snoopyTestCli_action_run_everything_showHelp ()
{
    char * helpContent =
        "Snoopy TEST SUITE CLI utility :: Action `run` :: Run everything (for Valgrind)\n"
        "\n"
        "Usage:\n"
        "    snoopy-test run everything\n"
        "\n"
        "Result:\n"
        "    Runs as many subsystems as possible, to cover as much code as possible.\n"
        "    Useful for Valgrind analysis.\n"
        "\n";
    printf("%s", helpContent);
}



int snoopyTestCli_action_run_everything ()
{
    char                     *logMessage = NULL;
    const snoopy_configuration_t * CFG;


    /* Initialize Snoopy */
    snoopy_entrypoint_test_cli_init((char const *)g_argv[0], g_argv, NULL);

    /* Get config pointer */
    CFG = snoopy_configuration_get();


    /* Initialize empty log message */
    logMessage    = malloc(CFG->log_message_max_length+1);
    logMessage[0] = '\0';


    /* Run throught as much code as possible */
#ifdef SNOOPY_FILTERING_ENABLED
    printf("-----[ Filters ]---------------------------------------\n");
    snoopyTestCli_action_run_filter_all();
#endif
    printf("-----[ Filtering ]-------------------------------------\n");
#ifdef SNOOPY_FILTERING_ENABLED
    snoopy_filtering_check_chain("exclude_uid:10,11,12;only_uid=0,1,2,3");
    printf("Done.\n");
#else
    printf("SKIPPED - not enabled.\n");
#endif
    printf("-----[ Datasources ]-----------------------------------\n");
    snoopyTestCli_action_run_datasource_all(CFG->datasource_message_max_length+1);
    printf("-----[ Outputs ]---------------------------------------\n");
    snoopyTestCli_action_run_output_all();


    printf("-----[ Message formatting ]----------------------------\n");
    snoopy_message_generateFromFormat(logMessage, CFG->log_message_max_length+1, CFG->datasource_message_max_length+1, CFG->message_format);
    printf("Message: %s\n", logMessage);


    printf("-----[ Dispatching ]-----------------------------------\n");
    snoopy_action_log_message_dispatch(logMessage);
    printf("Done.\n");

    printf("\nAll done.\n");


    /* Cleanup and return */
    free(logMessage);
    snoopy_entrypoint_test_cli_exit();

    /* Close these FDs too, otherwise valgrind complains */
    fclose(stdin);
    fclose(stdout);
    fclose(stderr);

    return 0;
}