]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Squashed commit of the following:
authorRuss Combs <rucombs@cisco.com>
Fri, 7 Aug 2015 00:53:03 +0000 (20:53 -0400)
committerRuss Combs <rucombs@cisco.com>
Fri, 7 Aug 2015 00:53:03 +0000 (20:53 -0400)
commit 9abf4418d24f8f1d0ef58f5e58b28d81f6565633
Author: Russ Combs <rucombs@cisco.com>
Date:   Wed Aug 5 14:56:14 2015 -0400

    add range and default to command line args
    fix unit test build on osx

configure.ac
src/Makefile.am
src/framework/parameter.cc
src/framework/parameter.h
src/main/help.cc
src/main/snort_module.cc
src/test/unit_test.cc

index 4a7900f607ad47c46141e8d66b4691cb1606628f..c27ab50d1c57f55006b96e0a03aa6d36c810967e 100644 (file)
@@ -61,6 +61,8 @@ if test "x$CXX" = "xg++"; then
     fi
 fi
 
+PKG_PROG_PKG_CONFIG
+
 #--------------------------------------------------------------------------
 # api options
 #--------------------------------------------------------------------------
@@ -471,7 +473,14 @@ fi
 AM_CONDITIONAL(BUILD_UNIT_TESTS, test "x$enable_unit_tests" = "xyes")
 
 if test "x$enable_unit_tests" = "xyes"; then
-    AC_CHECK_LIB(check,srunner_create)
+    PKG_CHECK_EXISTS([check], [ have_check_pkgconfig="yes" ], [ have_check_pkgconfig="no" ])
+
+    if test "${have_check_pkgconfig}" = "yes" ; then
+        CPPFLAGS="${CPPFLAGS} `pkg-config --cflags check 2>/dev/null`"
+        LIBS="${LIBS} `pkg-config --libs check 2>/dev/null`"
+    else
+        AC_CHECK_LIB(check,srunner_create)
+    fi
 fi
 
 #--------------------------------------------------------------------------
@@ -560,8 +569,6 @@ fi
 # luajit
 #--------------------------------------------------------------------------
 
-PKG_PROG_PKG_CONFIG
-
 PKG_CHECK_EXISTS([luajit], [ have_luajit_pkgconfig="yes" ], [ have_luajit_pkgconfig="no" ])
 
 if test "${have_luajit_pkgconfig}" = "yes" ; then
index 054be8e63a32fbc8f9b9b28c280862cfa66c7423..792b9c0288e2a81376e30f22b2f34a1af43602ae 100644 (file)
@@ -117,12 +117,12 @@ time \
 utils
 
 if BUILD_UNIT_TESTS
-snort_LDADD += test/libtest.a -lcheck -lrt -lpthread
 SUBDIRS += test
+snort_LDADD += test/libtest.a
 endif
 
 if BUILD_PIGLET
-snort_LDADD += piglet/libpiglet.a piglet_plugins/libpiglet_plugins.a
 SUBDIRS += piglet piglet_plugins
+snort_LDADD += piglet/libpiglet.a piglet_plugins/libpiglet_plugins.a
 endif
 
index b6128cfb49d5c3cdcf2b5e227f3922022fb238b2..ca03785eac1cf3551859f1c06f786ef70912df63 100644 (file)
@@ -132,9 +132,13 @@ static bool is_sep(char c)
 
 static const char* find(const char* r, const char* s)
 {
-    const char* t = strstr(r, s);
     unsigned n = strlen(s);
 
+    if ( !n )
+        return nullptr;
+
+    const char* t = strstr(r, s);
+
     while ( t )
     {
         if ( (t == r || is_sep(t[-1])) && is_sep(t[n]) )
index 0975f7b8ac3d1611c991dccc2e4b43c12831435d..a3c24742c74936e01262b16e5c30813300a2e901 100644 (file)
@@ -75,6 +75,9 @@ struct SO_PUBLIC Parameter
     bool is_quoted() const
     { return ( type > PT_PORT ); }
 
+    bool has_text_range() const
+    { return !is_table() and range != nullptr; }
+
     bool get_bool() const;
     double get_number() const;
     const char* get_string() const;
index d3a516461b0c9a3e00f07061cc4fb60f59049489..ed2f4671e74441d985d90f916342f3131ca0ea41 100644 (file)
@@ -95,12 +95,20 @@ void help_args(const char* pfx)
         if ( p->help && (!n || !strncasecmp(name, pfx, n)) )
         {
             cout << Markup::item();
-            cout << Markup::emphasis_on();
 
+            cout << Markup::emphasis_on();
             cout << Markup::escape(p->name);
             cout << Markup::emphasis_off();
 
             cout << " " << Markup::escape(p->help);
+
+            if ( p->has_text_range() )
+            {
+                if ( *((char*)p->range) == '(' )
+                    cout << " " << (char*)p->range;
+                else
+                    cout << " (" << (char*)p->range << ")";
+            }
             cout << endl;
         }
         ++p;
index b624c274e05e26e9bb3541fd7d7efd5e11baf5af..d186cacfb0a72436c3a4f23961ecaacafb3e4d07 100644 (file)
@@ -111,6 +111,10 @@ static void x2s(const char* s)
 
 //-------------------------------------------------------------------------
 // parameters
+//
+// users aren't used to seeing the standard help format for command line
+// args so the few cases where there is a default, we include it in the
+// help as well.
 //-------------------------------------------------------------------------
 
 static const Parameter s_params[] =
@@ -163,7 +167,7 @@ static const Parameter s_params[] =
 #endif
 
     { "-k", Parameter::PT_ENUM, "all|noip|notcp|noudp|noicmp|none", "all",
-      "<mode> checksum mode (all,noip,notcp,noudp,noicmp,none)" },
+      "<mode> checksum mode; default is all" },
 
     { "-L", Parameter::PT_STRING, nullptr, nullptr,
       "<mode> logging mode (none, dump, pcap, or log_*)" },
@@ -199,7 +203,7 @@ static const Parameter s_params[] =
       "<x=v> set config variable x equal to value v" },
 
     { "-s", Parameter::PT_INT, "68:65535", "1514",
-      "<snap> (same as --snaplen)" },
+      "<snap> (same as --snaplen); default is 1514" },
 
     { "-T", Parameter::PT_IMPLIED, nullptr, nullptr,
       "test and report on the current Snort configuration" },
@@ -238,7 +242,7 @@ static const Parameter s_params[] =
 
     { "-z", Parameter::PT_INT, "0:", "1",
       "<count> maximum number of packet threads (same as --max-packet-threads); "
-      "0 gets the number of CPU cores reported by the system" },
+      "0 gets the number of CPU cores reported by the system; default is 1" },
 
     { "--alert-before-pass", Parameter::PT_IMPLIED, nullptr, nullptr,
       "process alert, drop, sdrop, or reject before pass; "
@@ -433,7 +437,8 @@ static const Parameter s_params[] =
       "use drop, sdrop, and reject rules to ignore session traffic when not inline" },
 
 #ifdef UNIT_TEST
-    { "--unit-test", Parameter::PT_STRING, nullptr, nullptr,
+    { "--unit-test", Parameter::PT_SELECT,
+      "silent | minimal | normal | verbose | env (export CK_VERBOSITY)", nullptr,
       "<verbosity> run unit tests with given libcheck output mode" },
 #endif
     { "--version", Parameter::PT_IMPLIED, nullptr, nullptr,
index 4cac4299acc9d3b11215750190ce5879b8fa56c4..51fa2a56ddbf2aa082eeef7b92534bf5b9d6f758 100644 (file)
@@ -16,7 +16,7 @@
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //--------------------------------------------------------------------------
 // unit_test.h author Russ Combs <rucombs@cisco.com>
-//
+
 #include "unit_test.h"
 
 #include <stdlib.h>