[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Mon Apr 10 09:39:02 UTC 2017


The branch, master has been updated
       via  94b7672 third_party: Add cmocka 1.1.1
       via  686ac6b wafsamba: Add CHECK_CMOCKA function
      from  56df7cf auth3: fallback to "sam_ignoredomain" in make_auth3_context_for_ntlm()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 94b7672d48040a1630a25b0d8a79bd8349b15397
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 7 15:44:05 2017 +0200

    third_party: Add cmocka 1.1.1
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlet <abartlet at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Apr 10 11:38:13 CEST 2017 on sn-devel-144

commit 686ac6b17124eea6aadd8b067bcac89cd8b9686a
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 7 15:44:22 2017 +0200

    wafsamba: Add CHECK_CMOCKA function
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlet <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_third_party.py |    6 +
 testsuite/unittests/wscript              |   14 +-
 third_party/cmocka/cmocka.c              | 3306 ++++++++++++++++++++++++++++++
 third_party/cmocka/cmocka.h              | 2284 +++++++++++++++++++++
 third_party/cmocka/cmocka_private.h      |  163 ++
 third_party/cmocka/wscript               |   19 +
 third_party/wscript                      |    2 +
 wscript                                  |    6 +
 8 files changed, 5791 insertions(+), 9 deletions(-)
 create mode 100644 third_party/cmocka/cmocka.c
 create mode 100644 third_party/cmocka/cmocka.h
 create mode 100644 third_party/cmocka/cmocka_private.h
 create mode 100644 third_party/cmocka/wscript


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_third_party.py b/buildtools/wafsamba/samba_third_party.py
index 8cfa4df..ac77be7 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -33,3 +33,9 @@ def CHECK_POPT(conf):
     return conf.CHECK_BUNDLED_SYSTEM('popt', checkfunctions='poptGetContext', headers='popt.h')
 
 Build.BuildContext.CHECK_POPT = CHECK_POPT
+
+ at conf
+def CHECK_CMOCKA(conf):
+    return conf.CHECK_BUNDLED_SYSTEM_PKG('cmocka', minversion='1.1.1')
+
+Build.BuildContext.CHECK_CMOCKA = CHECK_CMOCKA
diff --git a/testsuite/unittests/wscript b/testsuite/unittests/wscript
index e256951..355ab0c 100644
--- a/testsuite/unittests/wscript
+++ b/testsuite/unittests/wscript
@@ -3,14 +3,10 @@
 import os
 
 def configure(conf):
-    pkg_name = 'cmocka'
-    pkg_minversion = '1.0'
-
-    conf.CHECK_BUNDLED_SYSTEM_PKG(pkg_name, minversion=pkg_minversion)
+    return
 
 def build(bld):
-    if bld.CONFIG_SET('HAVE_CMOCKA'):
-        bld.SAMBA_BINARY('test_krb5samba',
-                         source='test_krb5_samba.c',
-                         deps='krb5samba cmocka',
-                         install=False)
+    bld.SAMBA_BINARY('test_krb5samba',
+                     source='test_krb5_samba.c',
+                     deps='krb5samba cmocka',
+                     install=False)
diff --git a/third_party/cmocka/cmocka.c b/third_party/cmocka/cmocka.c
new file mode 100644
index 0000000..14b2765
--- /dev/null
+++ b/third_party/cmocka/cmocka.c
@@ -0,0 +1,3306 @@
+/*
+ * Copyright 2008 Google Inc.
+ * Copyright 2014-2015 Andreas Schneider <asn at cryptomilk.org>
+ * Copyright 2015      Jakub Hrozek <jakub.hrozek at posteo.se>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include <stdint.h>
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+/*
+ * This allows to add a platform specific header file. Some embedded platforms
+ * sometimes miss certain types and definitions.
+ *
+ * Example:
+ *
+ * typedef unsigned long int uintptr_t
+ * #define _UINTPTR_T 1
+ * #define _UINTPTR_T_DEFINED 1
+ */
+#ifdef CMOCKA_PLATFORM_INCLUDE
+# include "cmocka_platform.h"
+#endif /* CMOCKA_PLATFORM_INCLUDE */
+
+#include <cmocka.h>
+#include <cmocka_private.h>
+
+/* Size of guard bytes around dynamically allocated blocks. */
+#define MALLOC_GUARD_SIZE 16
+/* Pattern used to initialize guard blocks. */
+#define MALLOC_GUARD_PATTERN 0xEF
+/* Pattern used to initialize memory allocated with test_malloc(). */
+#define MALLOC_ALLOC_PATTERN 0xBA
+#define MALLOC_FREE_PATTERN 0xCD
+/* Alignment of allocated blocks.  NOTE: This must be base2. */
+#define MALLOC_ALIGNMENT sizeof(size_t)
+
+/* Printf formatting for source code locations. */
+#define SOURCE_LOCATION_FORMAT "%s:%u"
+
+#if defined(HAVE_GCC_THREAD_LOCAL_STORAGE)
+# define CMOCKA_THREAD __thread
+#elif defined(HAVE_MSVC_THREAD_LOCAL_STORAGE)
+# define CMOCKA_THREAD __declspec(thread)
+#else
+# define CMOCKA_THREAD
+#endif
+
+#ifdef HAVE_CLOCK_REALTIME
+#define CMOCKA_CLOCK_GETTIME(clock_id, ts) clock_gettime((clock_id), (ts))
+#else
+#define CMOCKA_CLOCK_GETTIME(clock_id, ts)
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) < (b) ? (b) : (a))
+#endif
+
+/**
+ * POSIX has sigsetjmp/siglongjmp, while Windows only has setjmp/longjmp.
+ */
+#ifdef HAVE_SIGLONGJMP
+# define cm_jmp_buf             sigjmp_buf
+# define cm_setjmp(env)         sigsetjmp(env, 1)
+# define cm_longjmp(env, val)   siglongjmp(env, val)
+#else
+# define cm_jmp_buf             jmp_buf
+# define cm_setjmp(env)         setjmp(env)
+# define cm_longjmp(env, val)   longjmp(env, val)
+#endif
+
+
+/*
+ * Declare and initialize the pointer member of ValuePointer variable name
+ * with ptr.
+ */
+#define declare_initialize_value_pointer_pointer(name, ptr) \
+    ValuePointer name ; \
+    name.value = 0; \
+    name.x.pointer = (void*)(ptr)
+
+/*
+ * Declare and initialize the value member of ValuePointer variable name
+ * with val.
+ */
+#define declare_initialize_value_pointer_value(name, val) \
+    ValuePointer name ; \
+    name.value = val
+
+/* Cast a LargestIntegralType to pointer_type via a ValuePointer. */
+#define cast_largest_integral_type_to_pointer( \
+    pointer_type, largest_integral_type) \
+    ((pointer_type)((ValuePointer*)&(largest_integral_type))->x.pointer)
+
+/* Used to cast LargetIntegralType to void* and vice versa. */
+typedef union ValuePointer {
+    LargestIntegralType value;
+    struct {
+#if defined(WORDS_BIGENDIAN) && (WORDS_SIZEOF_VOID_P == 4)
+        unsigned int padding;
+#endif
+        void *pointer;
+    } x;
+} ValuePointer;
+
+/* Doubly linked list node. */
+typedef struct ListNode {
+    const void *value;
+    int refcount;
+    struct ListNode *next;
+    struct ListNode *prev;
+} ListNode;
+
+/* Debug information for malloc(). */
+typedef struct MallocBlockInfo {
+    void* block;              /* Address of the block returned by malloc(). */
+    size_t allocated_size;    /* Total size of the allocated block. */
+    size_t size;              /* Request block size. */
+    SourceLocation location;  /* Where the block was allocated. */
+    ListNode node;            /* Node within list of all allocated blocks. */
+} MallocBlockInfo;
+
+/* State of each test. */
+typedef struct TestState {
+    const ListNode *check_point; /* Check point of the test if there's a */
+                                 /* setup function. */
+    void *state;                 /* State associated with the test. */
+} TestState;
+
+/* Determines whether two values are the same. */
+typedef int (*EqualityFunction)(const void *left, const void *right);
+
+/* Value of a symbol and the place it was declared. */
+typedef struct SymbolValue {
+    SourceLocation location;
+    LargestIntegralType value;
+} SymbolValue;
+
+/*
+ * Contains a list of values for a symbol.
+ * NOTE: Each structure referenced by symbol_values_list_head must have a
+ * SourceLocation as its' first member.
+ */
+typedef struct SymbolMapValue {
+    const char *symbol_name;
+    ListNode symbol_values_list_head;
+} SymbolMapValue;
+
+/* Where a particular ordering was located and its symbol name */
+typedef struct FuncOrderingValue {
+    SourceLocation location;
+    const char * function;
+} FuncOrderingValue;
+
+/* Used by list_free() to deallocate values referenced by list nodes. */
+typedef void (*CleanupListValue)(const void *value, void *cleanup_value_data);
+
+/* Structure used to check the range of integer types.a */
+typedef struct CheckIntegerRange {
+    CheckParameterEvent event;
+    LargestIntegralType minimum;
+    LargestIntegralType maximum;
+} CheckIntegerRange;
+
+/* Structure used to check whether an integer value is in a set. */
+typedef struct CheckIntegerSet {
+    CheckParameterEvent event;
+    const LargestIntegralType *set;
+    size_t size_of_set;
+} CheckIntegerSet;
+
+/* Used to check whether a parameter matches the area of memory referenced by
+ * this structure.  */
+typedef struct CheckMemoryData {
+    CheckParameterEvent event;
+    const void *memory;
+    size_t size;
+} CheckMemoryData;
+
+static ListNode* list_initialize(ListNode * const node);
+static ListNode* list_add(ListNode * const head, ListNode *new_node);
+static ListNode* list_add_value(ListNode * const head, const void *value,
+                                     const int count);
+static ListNode* list_remove(
+    ListNode * const node, const CleanupListValue cleanup_value,
+    void * const cleanup_value_data);
+static void list_remove_free(
+    ListNode * const node, const CleanupListValue cleanup_value,
+    void * const cleanup_value_data);
+static int list_empty(const ListNode * const head);
+static int list_find(
+    ListNode * const head, const void *value,
+    const EqualityFunction equal_func, ListNode **output);
+static int list_first(ListNode * const head, ListNode **output);
+static ListNode* list_free(
+    ListNode * const head, const CleanupListValue cleanup_value,
+    void * const cleanup_value_data);
+
+static void add_symbol_value(
+    ListNode * const symbol_map_head, const char * const symbol_names[],
+    const size_t number_of_symbol_names, const void* value, const int count);
+static int get_symbol_value(
+    ListNode * const symbol_map_head, const char * const symbol_names[],
+    const size_t number_of_symbol_names, void **output);
+static void free_value(const void *value, void *cleanup_value_data);
+static void free_symbol_map_value(
+    const void *value, void *cleanup_value_data);
+static void remove_always_return_values(ListNode * const map_head,
+                                        const size_t number_of_symbol_names);
+
+static int check_for_leftover_values_list(const ListNode * head,
+    const char * const error_message);
+
+static int check_for_leftover_values(
+    const ListNode * const map_head, const char * const error_message,
+    const size_t number_of_symbol_names);
+
+static void remove_always_return_values_from_list(ListNode * const map_head);
+
+/*
+ * This must be called at the beginning of a test to initialize some data
+ * structures.
+ */
+static void initialize_testing(const char *test_name);
+
+/* This must be called at the end of a test to free() allocated structures. */
+static void teardown_testing(const char *test_name);
+
+static enum cm_message_output cm_get_output(void);
+
+static int cm_error_message_enabled = 1;
+static CMOCKA_THREAD char *cm_error_message;
+
+void cm_print_error(const char * const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
+
+/*
+ * Keeps track of the calling context returned by setenv() so that the fail()
+ * method can jump out of a test.
+ */
+static CMOCKA_THREAD cm_jmp_buf global_run_test_env;
+static CMOCKA_THREAD int global_running_test = 0;
+
+/* Keeps track of the calling context returned by setenv() so that */
+/* mock_assert() can optionally jump back to expect_assert_failure(). */
+jmp_buf global_expect_assert_env;
+int global_expecting_assert = 0;
+const char *global_last_failed_assert = NULL;
+static int global_skip_test;
+
+/* Keeps a map of the values that functions will have to return to provide */
+/* mocked interfaces. */
+static CMOCKA_THREAD ListNode global_function_result_map_head;
+/* Location of the last mock value returned was declared. */
+static CMOCKA_THREAD SourceLocation global_last_mock_value_location;
+
+/* Keeps a map of the values that functions expect as parameters to their
+ * mocked interfaces. */
+static CMOCKA_THREAD ListNode global_function_parameter_map_head;
+/* Location of last parameter value checked was declared. */
+static CMOCKA_THREAD SourceLocation global_last_parameter_location;
+
+/* List (acting as FIFO) of call ordering. */
+static CMOCKA_THREAD ListNode global_call_ordering_head;
+/* Location of last call ordering that was declared. */
+static CMOCKA_THREAD SourceLocation global_last_call_ordering_location;
+
+/* List of all currently allocated blocks. */
+static CMOCKA_THREAD ListNode global_allocated_blocks;
+
+static enum cm_message_output global_msg_output = CM_OUTPUT_STDOUT;
+
+#ifndef _WIN32
+/* Signals caught by exception_handler(). */
+static const int exception_signals[] = {
+    SIGFPE,
+    SIGILL,
+    SIGSEGV,
+#ifdef SIGBUS
+    SIGBUS,
+#endif
+#ifdef SIGSYS
+    SIGSYS,
+#endif
+};
+
+/* Default signal functions that should be restored after a test is complete. */
+typedef void (*SignalFunction)(int signal);
+static SignalFunction default_signal_functions[
+    ARRAY_SIZE(exception_signals)];
+
+#else /* _WIN32 */
+
+/* The default exception filter. */
+static LPTOP_LEVEL_EXCEPTION_FILTER previous_exception_filter;
+
+/* Fatal exceptions. */
+typedef struct ExceptionCodeInfo {
+    DWORD code;
+    const char* description;
+} ExceptionCodeInfo;
+
+#define EXCEPTION_CODE_INFO(exception_code) {exception_code, #exception_code}
+
+static const ExceptionCodeInfo exception_codes[] = {
+    EXCEPTION_CODE_INFO(EXCEPTION_ACCESS_VIOLATION),
+    EXCEPTION_CODE_INFO(EXCEPTION_ARRAY_BOUNDS_EXCEEDED),
+    EXCEPTION_CODE_INFO(EXCEPTION_DATATYPE_MISALIGNMENT),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_DENORMAL_OPERAND),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_DIVIDE_BY_ZERO),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_INEXACT_RESULT),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_INVALID_OPERATION),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_OVERFLOW),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_STACK_CHECK),
+    EXCEPTION_CODE_INFO(EXCEPTION_FLT_UNDERFLOW),
+    EXCEPTION_CODE_INFO(EXCEPTION_GUARD_PAGE),
+    EXCEPTION_CODE_INFO(EXCEPTION_ILLEGAL_INSTRUCTION),
+    EXCEPTION_CODE_INFO(EXCEPTION_INT_DIVIDE_BY_ZERO),
+    EXCEPTION_CODE_INFO(EXCEPTION_INT_OVERFLOW),
+    EXCEPTION_CODE_INFO(EXCEPTION_INVALID_DISPOSITION),
+    EXCEPTION_CODE_INFO(EXCEPTION_INVALID_HANDLE),
+    EXCEPTION_CODE_INFO(EXCEPTION_IN_PAGE_ERROR),
+    EXCEPTION_CODE_INFO(EXCEPTION_NONCONTINUABLE_EXCEPTION),
+    EXCEPTION_CODE_INFO(EXCEPTION_PRIV_INSTRUCTION),
+    EXCEPTION_CODE_INFO(EXCEPTION_STACK_OVERFLOW),
+};
+#endif /* !_WIN32 */
+
+enum CMUnitTestStatus {
+    CM_TEST_NOT_STARTED,
+    CM_TEST_PASSED,
+    CM_TEST_FAILED,
+    CM_TEST_ERROR,
+    CM_TEST_SKIPPED,
+};
+
+struct CMUnitTestState {
+    const ListNode *check_point; /* Check point of the test if there's a setup function. */
+    const struct CMUnitTest *test; /* Point to array element in the tests we get passed */
+    void *state; /* State associated with the test */
+    const char *error_message; /* The error messages by the test */
+    enum CMUnitTestStatus status; /* PASSED, FAILED, ABORT ... */
+    double runtime; /* Time calculations */
+};
+
+/* Exit the currently executing test. */
+static void exit_test(const int quit_application)
+{
+    const char *abort_test = getenv("CMOCKA_TEST_ABORT");
+
+    if (abort_test != NULL && abort_test[0] == '1') {
+        print_error("%s", cm_error_message);
+        abort();
+    } else if (global_running_test) {
+        cm_longjmp(global_run_test_env, 1);
+    } else if (quit_application) {
+        exit(-1);
+    }
+}
+
+void _skip(const char * const file, const int line)
+{
+    cm_print_error(SOURCE_LOCATION_FORMAT ": Skipped!\n", file, line);
+    global_skip_test = 1;
+    exit_test(1);
+}
+
+/* Initialize a SourceLocation structure. */
+static void initialize_source_location(SourceLocation * const location) {
+    assert_non_null(location);
+    location->file = NULL;
+    location->line = 0;
+}
+
+
+/* Determine whether a source location is currently set. */
+static int source_location_is_set(const SourceLocation * const location) {
+    assert_non_null(location);
+    return location->file && location->line;
+}
+
+
+/* Set a source location. */
+static void set_source_location(
+    SourceLocation * const location, const char * const file,
+    const int line) {
+    assert_non_null(location);
+    location->file = file;
+    location->line = line;
+}
+
+
+static int c_strreplace(char *src,
+                        size_t src_len,
+                        const char *pattern,
+                        const char *repl,
+                        int *str_replaced)
+{
+    char *p = NULL;
+
+    p = strstr(src, pattern);
+    if (p == NULL) {
+        return -1;
+    }
+
+    do {
+        size_t of = p - src;
+        size_t l  = strlen(src);
+        size_t pl = strlen(pattern);
+        size_t rl = strlen(repl);
+
+        /* overflow check */
+        if (src_len <= l + MAX(pl, rl) + 1) {
+            return -1;
+        }
+
+        if (rl != pl) {
+            memmove(src + of + rl, src + of + pl, l - of - pl + 1);
+        }
+
+        strncpy(src + of, repl, rl);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list