From 1e973565b6c0cb738b25a2d9439d5acb441701f4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 27 Apr 2008 14:02:46 +0100 Subject: Move subunit infrastructure code into lib/torture. (This used to be commit 5b44d8121de7735d69e6238a1442aff034a8ebd3) --- source4/lib/basic.mk | 1 + source4/lib/crypto/sha1test.c | 2 +- source4/lib/torture/config.mk | 11 + source4/lib/torture/torture.c | 579 ++++++++++++++++++++++++++++++++++++++++++ source4/lib/torture/torture.h | 396 +++++++++++++++++++++++++++++ source4/lib/util/tests/str.c | 2 +- 6 files changed, 989 insertions(+), 2 deletions(-) create mode 100644 source4/lib/torture/config.mk create mode 100644 source4/lib/torture/torture.c create mode 100644 source4/lib/torture/torture.h (limited to 'source4/lib') diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index 71acb94492..e7e0ba80c4 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -16,6 +16,7 @@ mkinclude util/config.mk mkinclude tdr/config.mk mkinclude dbwrap/config.mk mkinclude crypto/config.mk +mkinclude torture/config.mk [SUBSYSTEM::LIBCOMPRESSION] diff --git a/source4/lib/crypto/sha1test.c b/source4/lib/crypto/sha1test.c index 0e943bd74d..7777764277 100644 --- a/source4/lib/crypto/sha1test.c +++ b/source4/lib/crypto/sha1test.c @@ -17,7 +17,7 @@ */ #include "includes.h" -#include "torture/ui.h" +#include "torture/torture.h" #include "lib/crypto/crypto.h" diff --git a/source4/lib/torture/config.mk b/source4/lib/torture/config.mk new file mode 100644 index 0000000000..e981ee0c99 --- /dev/null +++ b/source4/lib/torture/config.mk @@ -0,0 +1,11 @@ +# TORTURE subsystem +[LIBRARY::torture] +PUBLIC_DEPENDENCIES = \ + LIBSAMBA-HOSTCONFIG \ + LIBSAMBA-UTIL \ + LIBTALLOC + +PC_FILES += lib/torture/torture.pc +torture_OBJ_FILES = $(addprefix lib/torture/, torture.o) + +PUBLIC_HEADERS += lib/torture/torture.h diff --git a/source4/lib/torture/torture.c b/source4/lib/torture/torture.c new file mode 100644 index 0000000000..3f2c7848aa --- /dev/null +++ b/source4/lib/torture/torture.c @@ -0,0 +1,579 @@ +/* + Unix SMB/CIFS implementation. + SMB torture UI functions + + Copyright (C) Jelmer Vernooij 2006 + + 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 3 of the License, 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, see . +*/ + +#include "includes.h" +#include "torture/torture.h" +#include "lib/util/dlinklist.h" +#include "param/param.h" +#include "system/filesys.h" +#include "auth/credentials/credentials.h" +#include "lib/cmdline/popt_common.h" + +struct torture_context *torture_context_init(struct event_context *event_ctx, + const struct torture_ui_ops *ui_ops) +{ + struct torture_context *torture = talloc_zero(event_ctx, + struct torture_context); + torture->ui_ops = ui_ops; + torture->returncode = true; + torture->ev = event_ctx; + + if (ui_ops->init) + ui_ops->init(torture); + + return torture; +} + +/** + create a temporary directory. +*/ +_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx, + const char *prefix, + char **tempdir) +{ + SMB_ASSERT(tctx->outputdir != NULL); + + *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir, + prefix); + NT_STATUS_HAVE_NO_MEMORY(*tempdir); + + if (mkdtemp(*tempdir) == NULL) { + return map_nt_error_from_unix(errno); + } + + return NT_STATUS_OK; +} + +void torture_comment(struct torture_context *context, const char *comment, ...) +{ + va_list ap; + char *tmp; + + if (!context->ui_ops->comment) + return; + + va_start(ap, comment); + tmp = talloc_vasprintf(context, comment, ap); + + context->ui_ops->comment(context, tmp); + + talloc_free(tmp); +} + +void torture_warning(struct torture_context *context, const char *comment, ...) +{ + va_list ap; + char *tmp; + + if (!context->ui_ops->warning) + return; + + va_start(ap, comment); + tmp = talloc_vasprintf(context, comment, ap); + + context->ui_ops->warning(context, tmp); + + talloc_free(tmp); +} + +void torture_result(struct torture_context *context, + enum torture_result result, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + + if (context->last_reason) { + torture_warning(context, "%s", context->last_reason); + talloc_free(context->last_reason); + } + + context->last_result = result; + context->last_reason = talloc_vasprintf(context, fmt, ap); + va_end(ap); +} + +struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name) +{ + struct torture_suite *suite = talloc_zero(ctx, struct torture_suite); + + suite->name = talloc_strdup(suite, name); + suite->testcases = NULL; + suite->children = NULL; + + return suite; +} + +void torture_tcase_set_fixture(struct torture_tcase *tcase, + bool (*setup) (struct torture_context *, void **), + bool (*teardown) (struct torture_context *, void *)) +{ + tcase->setup = setup; + tcase->teardown = teardown; +} + +static bool wrap_test_with_testcase_const(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, + const void *tcase_data, + const void *test_data); + + fn = test->fn; + + return fn(torture_ctx, tcase->data, test->data); +} + +struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase, + const char *name, + bool (*run) (struct torture_context *, const void *tcase_data, + const void *test_data), + const void *data) +{ + struct torture_test *test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_test_with_testcase_const; + test->fn = run; + test->dangerous = false; + test->data = data; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return test; +} + + +bool torture_suite_init_tcase(struct torture_suite *suite, + struct torture_tcase *tcase, + const char *name) +{ + tcase->name = talloc_strdup(tcase, name); + tcase->description = NULL; + tcase->setup = NULL; + tcase->teardown = NULL; + tcase->fixture_persistent = true; + tcase->tests = NULL; + + DLIST_ADD_END(suite->testcases, tcase, struct torture_tcase *); + + return true; +} + + +struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite, + const char *name) +{ + struct torture_tcase *tcase = talloc(suite, struct torture_tcase); + + if (!torture_suite_init_tcase(suite, tcase, name)) + return NULL; + + return tcase; +} + +bool torture_run_suite(struct torture_context *context, + struct torture_suite *suite) +{ + bool ret = true; + struct torture_tcase *tcase; + struct torture_suite *tsuite; + char *old_testname; + + context->level++; + if (context->ui_ops->suite_start) + context->ui_ops->suite_start(context, suite); + + old_testname = context->active_testname; + if (old_testname != NULL) + context->active_testname = talloc_asprintf(context, "%s-%s", + old_testname, suite->name); + else + context->active_testname = talloc_strdup(context, suite->name); + + for (tcase = suite->testcases; tcase; tcase = tcase->next) { + ret &= torture_run_tcase(context, tcase); + } + + for (tsuite = suite->children; tsuite; tsuite = tsuite->next) { + ret &= torture_run_suite(context, tsuite); + } + + talloc_free(context->active_testname); + context->active_testname = old_testname; + + if (context->ui_ops->suite_finish) + context->ui_ops->suite_finish(context, suite); + + context->level--; + + return ret; +} + +void torture_ui_test_start(struct torture_context *context, + struct torture_tcase *tcase, + struct torture_test *test) +{ + if (context->ui_ops->test_start) + context->ui_ops->test_start(context, tcase, test); +} + +int str_list_match(const char *name, char **list) +{ + int i, ret = 0; + if (list == NULL) + return 0; + + for (i = 0; list[i]; i++) { + if (gen_fnmatch(list[i], name) == 0) + ret++; + } + return ret; +} + +void torture_ui_test_result(struct torture_context *context, + enum torture_result result, + const char *comment) +{ + if (context->ui_ops->test_result) + context->ui_ops->test_result(context, result, comment); + + if (result == TORTURE_ERROR || result == TORTURE_FAIL) + context->returncode = false; +} + +static bool internal_torture_run_test(struct torture_context *context, + struct torture_tcase *tcase, + struct torture_test *test, + bool already_setup) +{ + bool success; + char *old_testname; + + if (tcase == NULL || strcmp(test->name, tcase->name) != 0) { + old_testname = context->active_testname; + context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name); + } + + context->active_tcase = tcase; + context->active_test = test; + + torture_ui_test_start(context, tcase, test); + + context->last_reason = NULL; + context->last_result = TORTURE_OK; + + if (!already_setup && tcase->setup && + !tcase->setup(context, &(tcase->data))) { + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "Setup failure"); + context->last_result = TORTURE_ERROR; + success = false; + } else if (test->dangerous && + !torture_setting_bool(context, "dangerous", false)) { + context->last_result = TORTURE_SKIP; + context->last_reason = talloc_asprintf(context, + "disabled %s - enable dangerous tests to use", test->name); + success = true; + } else { + success = test->run(context, tcase, test); + + if (!success && context->last_result == TORTURE_OK) { + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "Unknown error/failure"); + context->last_result = TORTURE_ERROR; + } + } + + if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) { + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "Setup failure"); + context->last_result = TORTURE_ERROR; + success = false; + } + + torture_ui_test_result(context, context->last_result, + context->last_reason); + + talloc_free(context->last_reason); + + if (tcase == NULL || strcmp(test->name, tcase->name) != 0) { + talloc_free(context->active_testname); + context->active_testname = old_testname; + } + context->active_test = NULL; + context->active_tcase = NULL; + + return success; +} + +bool torture_run_tcase(struct torture_context *context, + struct torture_tcase *tcase) +{ + bool ret = true; + char *old_testname; + struct torture_test *test; + + context->level++; + + context->active_tcase = tcase; + if (context->ui_ops->tcase_start) + context->ui_ops->tcase_start(context, tcase); + + if (tcase->fixture_persistent && tcase->setup + && !tcase->setup(context, &tcase->data)) { + /* FIXME: Use torture ui ops for reporting this error */ + fprintf(stderr, "Setup failed: "); + if (context->last_reason != NULL) + fprintf(stderr, "%s", context->last_reason); + fprintf(stderr, "\n"); + ret = false; + goto done; + } + + old_testname = context->active_testname; + context->active_testname = talloc_asprintf(context, "%s-%s", + old_testname, tcase->name); + for (test = tcase->tests; test; test = test->next) { + ret &= internal_torture_run_test(context, tcase, test, + tcase->fixture_persistent); + } + talloc_free(context->active_testname); + context->active_testname = old_testname; + + if (tcase->fixture_persistent && tcase->teardown && + !tcase->teardown(context, tcase->data)) + ret = false; + +done: + context->active_tcase = NULL; + + if (context->ui_ops->tcase_finish) + context->ui_ops->tcase_finish(context, tcase); + + context->level--; + + return ret; +} + +bool torture_run_test(struct torture_context *context, + struct torture_tcase *tcase, + struct torture_test *test) +{ + return internal_torture_run_test(context, tcase, test, false); +} + +int torture_setting_int(struct torture_context *test, const char *name, + int default_value) +{ + return lp_parm_int(test->lp_ctx, NULL, "torture", name, default_value); +} + +double torture_setting_double(struct torture_context *test, const char *name, + double default_value) +{ + return lp_parm_double(test->lp_ctx, NULL, "torture", name, default_value); +} + +bool torture_setting_bool(struct torture_context *test, const char *name, + bool default_value) +{ + return lp_parm_bool(test->lp_ctx, NULL, "torture", name, default_value); +} + +const char *torture_setting_string(struct torture_context *test, + const char *name, + const char *default_value) +{ + const char *ret; + + SMB_ASSERT(test != NULL); + SMB_ASSERT(test->lp_ctx != NULL); + + ret = lp_parm_string(test->lp_ctx, NULL, "torture", name); + + if (ret == NULL) + return default_value; + + return ret; +} + +static bool wrap_test_with_simple_tcase_const ( + struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, const void *tcase_data); + + fn = test->fn; + + return fn(torture_ctx, test->data); +} + +struct torture_tcase *torture_suite_add_simple_tcase_const( + struct torture_suite *suite, const char *name, + bool (*run) (struct torture_context *test, const void *), + const void *data) +{ + struct torture_tcase *tcase; + struct torture_test *test; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_test_with_simple_tcase_const; + test->fn = run; + test->data = data; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return tcase; +} + +static bool wrap_simple_test(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *); + + fn = test->fn; + + return fn(torture_ctx); +} + +struct torture_tcase *torture_suite_add_simple_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *test)) +{ + struct torture_test *test; + struct torture_tcase *tcase; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_simple_test; + test->fn = run; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return tcase; +} + +bool torture_suite_add_suite(struct torture_suite *suite, + struct torture_suite *child) +{ + if (child == NULL) + return false; + + DLIST_ADD_END(suite->children, child, struct torture_suite *); + + /* FIXME: Check for duplicates and return false if the + * added suite already exists as a child */ + + return true; +} + + +struct torture_suite *torture_find_suite(struct torture_suite *parent, + const char *name) +{ + struct torture_suite *child; + + for (child = parent->children; child; child = child->next) + if (!strcmp(child->name, name)) + return child; + + return NULL; +} + +static bool wrap_test_with_simple_test_const(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, const void *tcase_data); + + fn = test->fn; + + return fn(torture_ctx, tcase->data); +} + +struct torture_test *torture_tcase_add_simple_test_const( + struct torture_tcase *tcase, + const char *name, + bool (*run) (struct torture_context *test, + const void *tcase_data)) +{ + struct torture_test *test; + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_test_with_simple_test_const; + test->fn = run; + test->data = NULL; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return test; +} + +static bool wrap_test_with_simple_test(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, void *tcase_data); + + fn = test->fn; + + return fn(torture_ctx, tcase->data); +} + +struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase, + const char *name, + bool (*run) (struct torture_context *test, void *tcase_data)) +{ + struct torture_test *test; + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_test_with_simple_test; + test->fn = run; + test->data = NULL; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return test; +} diff --git a/source4/lib/torture/torture.h b/source4/lib/torture/torture.h new file mode 100644 index 0000000000..15b04c2397 --- /dev/null +++ b/source4/lib/torture/torture.h @@ -0,0 +1,396 @@ +/* + Unix SMB/CIFS implementation. + SMB torture UI functions + + Copyright (C) Jelmer Vernooij 2006 + + 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 3 of the License, 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, see . +*/ + +#ifndef __TORTURE_UI_H__ +#define __TORTURE_UI_H__ + +struct torture_test; +struct torture_context; +struct torture_suite; +struct torture_tcase; + +enum torture_result { + TORTURE_OK=0, + TORTURE_FAIL=1, + TORTURE_ERROR=2, + TORTURE_SKIP=3 +}; + +/* + * These callbacks should be implemented by any backend that wishes + * to listen to reports from the torture tests. + */ +struct torture_ui_ops +{ + void (*init) (struct torture_context *); + void (*comment) (struct torture_context *, const char *); + void (*warning) (struct torture_context *, const char *); + void (*suite_start) (struct torture_context *, struct torture_suite *); + void (*suite_finish) (struct torture_context *, struct torture_suite *); + void (*tcase_start) (struct torture_context *, struct torture_tcase *); + void (*tcase_finish) (struct torture_context *, struct torture_tcase *); + void (*test_start) (struct torture_context *, + struct torture_tcase *, + struct torture_test *); + void (*test_result) (struct torture_context *, + enum torture_result, const char *reason); +}; + +void torture_ui_test_start(struct torture_context *context, + struct torture_tcase *tcase, + struct torture_test *test); + +void torture_ui_test_result(struct torture_context *context, + enum torture_result result, + const char *comment); + +/* + * Holds information about a specific run of the testsuite. + * The data in this structure should be considered private to + * the torture tests and should only be used directly by the torture + * code and the ui backends. + * + * Torture tests should instead call the torture_*() macros and functions + * specified below. + */ + +struct torture_context +{ + const struct torture_ui_ops *ui_ops; + void *ui_data; + + char *active_testname; + struct torture_test *active_test; + struct torture_tcase *active_tcase; + + bool quiet; /* Whether tests should avoid writing output to stdout */ + + enum torture_result last_result; + char *last_reason; + + bool returncode; + + const char *outputdir; + int level; + struct event_context *ev; + + struct loadparm_context *lp_ctx; +}; + +/* + * Describes a particular torture test + */ +struct torture_test { + const char *name; + const char *description; + bool dangerous; + /* Function to call to run this test */ + bool (*run) (struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test); + + struct torture_test *prev, *next; + + /* Pointer to the actual test function. This is run by the + * run() function above. */ + void *fn; + const void *data; +}; + +/* + * Describes a particular test case. + */ +struct torture_tcase { + const char *name; + const char *description; + bool (*setup) (struct torture_context *tcase, void **data); + bool (*teardown) (struct torture_context *tcase, void *data); + bool fixture_persistent; + void *data; + struct torture_test *tests; + struct torture_tcase *prev, *next; +}; + +struct torture_suite +{ + const char *name; + const char *description; + struct torture_tcase *testcases; + struct torture_suite *children; + + /* Pointers to siblings of this torture suite */ + struct torture_suite *prev, *next; +}; + +/** Create a new torture suite */ +struct torture_suite *torture_suite_create(TALLOC_CTX *mem_ctx, + const char *name); + +/** Change the setup and teardown functions for a testcase */ +void torture_tcase_set_fixture(struct torture_tcase *tcase, + bool (*setup) (struct torture_context *, void **), + bool (*teardown) (struct torture_context *, void *)); + +/* Add another test to run for a particular testcase */ +struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase, + const char *name, + bool (*run) (struct torture_context *test, + const void *tcase_data, const void *test_data), + const void *test_data); + +/* Add a testcase to a testsuite */ +struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite, + const char *name); + +/* Convenience wrapper that adds a testcase against only one + * test will be run */ +struct torture_tcase *torture_suite_add_simple_tcase_const( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *test, + const void *test_data), + const void *data); + +/* Convenience function that adds a test which only + * gets the test case data */ +struct torture_test *torture_tcase_add_simple_test_const( + struct torture_tcase *tcase, + const char *name, + bool (*run) (struct torture_context *test, + const void *tcase_data)); + +/* Convenience wrapper that adds a test that doesn't need any + * testcase data */ +struct torture_tcase *torture_suite_add_simple_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *test)); + +/* Add a child testsuite to an existing testsuite */ +bool torture_suite_add_suite(struct torture_suite *suite, + struct torture_suite *child); + +/* Run the specified testsuite recursively */ +bool torture_run_suite(struct torture_context *context, + struct torture_suite *suite); + +/* Run the specified testcase */ +bool torture_run_tcase(struct torture_context *context, + struct torture_tcase *tcase); + +/* Run the specified test */ +bool torture_run_test(struct torture_context *context, + struct torture_tcase *tcase, + struct torture_test *test); + +void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3); +void torture_warning(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3); +void torture_result(struct torture_context *test, + enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4); + +#define torture_assert(torture_ctx,expr,cmt) \ + if (!(expr)) { \ + torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \ + return false; \ + } + +#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \ + do { WERROR __got = got, __expected = expected; \ + if (!W_ERROR_EQUAL(__got, __expected)) { \ + torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", win_errstr(__got), win_errstr(__expected), cmt); \ + return false; \ + } \ + } while (0) + +#define torture_assert_ntstatus_equal(torture_ctx,got,expected,cmt) \ + do { NTSTATUS __got = got, __expected = expected; \ + if (!NT_STATUS_EQUAL(__got, __expected)) { \ + torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \ + return false; \ + }\ + } while(0) + +#define torture_assert_ndr_err_equal(torture_ctx,got,expected,cmt) \ + do { enum ndr_err_code __got = got, __expected = expected; \ + if (__got != __expected) { \ + torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %d, expected %d (%s): %s", __got, __expected, __STRING(expected), cmt); \ + return false; \ + }\ + } while(0) + +#define torture_assert_casestr_equal(torture_ctx,got,expected,cmt) \ + do { const char *__got = (got), *__expected = (expected); \ + if (!strequal(__got, __expected)) { \ + torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", __got, __expected, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\ + do { const char *__got = (got), *__expected = (expected); \ + if (strcmp_safe(__got, __expected) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" was %s, expected %s: %s", \ + __got, __expected, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\ + do { const void *__got = (got), *__expected = (expected); \ + if (memcmp(__got, __expected, len) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" of len %d did not match"#expected": %s", len, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_file_contains_text(torture_ctx,filename,expected,cmt)\ + do { \ + char *__got; \ + const char *__expected = (expected); \ + size_t __size; \ + __got = file_load(filename, &__size, torture_ctx); \ + if (__got == NULL) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": unable to open %s: %s\n", \ + filename, cmt); \ + return false; \ + } \ + \ + if (strcmp_safe(__got, __expected) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": %s contained:\n%sExpected: %s%s\n", \ + filename, __got, __expected, cmt); \ + talloc_free(__got); \ + return false; \ + } \ + talloc_free(__got); \ + } while(0) + +#define torture_assert_file_contains(torture_ctx,filename,expected,cmt)\ + do { const char *__got, *__expected = (expected); \ + size_t __size; \ + __got = file_load(filename, *size, torture_ctx); \ + if (strcmp_safe(__got, __expected) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": %s contained:\n%sExpected: %s%s\n", \ + __got, __expected, cmt); \ + talloc_free(__got); \ + return false; \ + } \ + talloc_free(__got); \ + } while(0) + +#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\ + do { int __got = (got), __expected = (expected); \ + if (__got != __expected) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" was %d, expected %d: %s", \ + __got, __expected, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_u64_equal(torture_ctx,got,expected,cmt)\ + do { uint64_t __got = (got), __expected = (expected); \ + if (__got != __expected) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" was %llu, expected %llu: %s", \ + (unsigned long long)__got, (unsigned long long)__expected, cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_errno_equal(torture_ctx,expected,cmt)\ + do { int __expected = (expected); \ + if (errno != __expected) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": errno was %d (%s), expected %d: %s: %s", \ + errno, strerror(errno), __expected, \ + strerror(__expected), cmt); \ + return false; \ + } \ + } while(0) + + + +#define torture_skip(torture_ctx,cmt) do {\ + torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\ + return true; \ + } while(0) +#define torture_fail(torture_ctx,cmt) do {\ + torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\ + return false; \ + } while (0) +#define torture_fail_goto(torture_ctx,label,cmt) do {\ + torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\ + goto label; \ + } while (0) + +#define torture_out stderr + +/* Convenience macros */ +#define torture_assert_ntstatus_ok(torture_ctx,expr,cmt) \ + torture_assert_ntstatus_equal(torture_ctx,expr,NT_STATUS_OK,cmt) + +#define torture_assert_werr_ok(torture_ctx,expr,cmt) \ + torture_assert_werr_equal(torture_ctx,expr,WERR_OK,cmt) + +#define torture_assert_ndr_success(torture_ctx,expr,cmt) \ + torture_assert_ndr_err_equal(torture_ctx,expr,NDR_ERR_SUCCESS,cmt) + +/* Getting settings */ +const char *torture_setting_string(struct torture_context *test, \ + const char *name, + const char *default_value); + +int torture_setting_int(struct torture_context *test, + const char *name, + int default_value); + +double torture_setting_double(struct torture_context *test, + const char *name, + double default_value); + +bool torture_setting_bool(struct torture_context *test, + const char *name, + bool default_value); + +struct torture_suite *torture_find_suite(struct torture_suite *parent, + const char *name); + +NTSTATUS torture_temp_dir(struct torture_context *tctx, + const char *prefix, + char **tempdir); + +struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase, + const char *name, + bool (*run) (struct torture_context *test, void *tcase_data)); + + +bool torture_suite_init_tcase(struct torture_suite *suite, + struct torture_tcase *tcase, + const char *name); + +struct torture_context *torture_context_init(struct event_context *event_ctx, + const struct torture_ui_ops *ui_ops); + +#endif /* __TORTURE_UI_H__ */ diff --git a/source4/lib/util/tests/str.c b/source4/lib/util/tests/str.c index a219ef0891..3bd6a02fdc 100644 --- a/source4/lib/util/tests/str.c +++ b/source4/lib/util/tests/str.c @@ -20,7 +20,7 @@ */ #include "includes.h" -#include "torture/ui.h" +#include "torture/torture.h" static bool test_string_sub_simple(struct torture_context *tctx) { -- cgit From f51a79889c769f0a30eef5bd8a486e08c6bbdad2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 May 2008 12:38:55 +0200 Subject: libreplace: check how portable utimes() and futimes() are metze (This used to be commit 8798ce3c744025b94973784dcb44d099427ef190) --- source4/lib/replace/system/config.m4 | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib') diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index 66c2bd652a..ae26bb5590 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -9,6 +9,7 @@ AC_CHECK_HEADERS(sys/select.h) # time AC_CHECK_HEADERS(sys/time.h utime.h) AC_HEADER_TIME +AC_CHECK_FUNCS(utime utimes futimes) # wait AC_HEADER_SYS_WAIT -- cgit From bbf4ce91462598cee1eebfb94a773194e56a7ff8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 13:10:31 +0200 Subject: libreplace: always provide utime() and utimes() I'd like to also provide futimes(), but it seems that some systems doesn't support a it at kernel level. If someone knows how to write a portable replacement for futimes() please tell me... metze (This used to be commit a9604fe4a323dccb537cf02ea7594437b4995803) --- source4/lib/replace/README | 2 + source4/lib/replace/replace.c | 27 +++++++ source4/lib/replace/replace.h | 10 +++ source4/lib/replace/system/config.m4 | 2 +- source4/lib/replace/system/time.h | 15 ++++ source4/lib/replace/test/testsuite.c | 145 +++++++++++++++++++++++++++++++++++ 6 files changed, 200 insertions(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/replace/README b/source4/lib/replace/README index 43f7b08572..4d94317c4b 100644 --- a/source4/lib/replace/README +++ b/source4/lib/replace/README @@ -62,6 +62,8 @@ getnameinfo gai_strerror getifaddrs freeifaddrs +utime +utimes Types: bool diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c index 443da2ab24..2c3f14c2df 100644 --- a/source4/lib/replace/replace.c +++ b/source4/lib/replace/replace.c @@ -584,3 +584,30 @@ int rep_unsetenv(const char *name) return 0; } #endif + +#ifndef HAVE_UTIME +int rep_utime(const char *filename, const struct utimbuf *buf) +{ + errno = ENOSYS; + return -1; +} +#endif + +#ifndef HAVE_UTIMES +int rep_utimes(const char *filename, const struct timeval tv[2]) +{ + struct utimbuf u; + + u.actime = tv[0].tv_sec; + if (tv[0].tv_usec > 500000) { + u.actime += 1; + } + + u.modtime = tv[1].tv_sec; + if (tv[1].tv_usec > 500000) { + u.modtime += 1; + } + + return utime(filename, &u); +} +#endif diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h index bf95169352..c69ea6cdac 100644 --- a/source4/lib/replace/replace.h +++ b/source4/lib/replace/replace.h @@ -101,6 +101,16 @@ void *rep_memmove(void *dest,const void *src,int size); /* prototype is in "system/time.h" */ #endif +#ifndef HAVE_UTIME +#define utime rep_utime +/* prototype is in "system/time.h" */ +#endif + +#ifndef HAVE_UTIMES +#define utimes rep_utimes +/* prototype is in "system/time.h" */ +#endif + #ifndef HAVE_STRLCPY #define strlcpy rep_strlcpy size_t rep_strlcpy(char *d, const char *s, size_t bufsize); diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4 index ae26bb5590..5c9b53d5c5 100644 --- a/source4/lib/replace/system/config.m4 +++ b/source4/lib/replace/system/config.m4 @@ -9,7 +9,7 @@ AC_CHECK_HEADERS(sys/select.h) # time AC_CHECK_HEADERS(sys/time.h utime.h) AC_HEADER_TIME -AC_CHECK_FUNCS(utime utimes futimes) +AC_CHECK_FUNCS(utime utimes) # wait AC_HEADER_SYS_WAIT diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h index 036812ab8f..4abf295d1a 100644 --- a/source4/lib/replace/system/time.h +++ b/source4/lib/replace/system/time.h @@ -39,6 +39,11 @@ #ifdef HAVE_UTIME_H #include +#else +struct utimbuf { + time_t actime; /* access time */ + time_t modtime; /* modification time */ +}; #endif #ifndef HAVE_MKTIME @@ -51,4 +56,14 @@ time_t rep_mktime(struct tm *t); time_t rep_timegm(struct tm *tm); #endif +#ifndef HAVE_UTIME +/* define is in "replace.h" */ +int rep_utime(const char *filename, const struct utimbuf *buf); +#endif + +#ifndef HAVE_UTIMES +/* define is in "replace.h" */ +int rep_utimes(const char *filename, const struct timeval tv[2]); +#endif + #endif diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c index b538360365..1e8290906e 100644 --- a/source4/lib/replace/test/testsuite.c +++ b/source4/lib/replace/test/testsuite.c @@ -872,6 +872,149 @@ static int test_getifaddrs(void) return true; } +static int test_utime(void) +{ + struct utimbuf u; + struct stat st1, st2, st3; + int fd; + + printf("test: utime\n"); + unlink(TESTFILE); + + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: utime [\n" + "creating '%s' failed - %s\n]\n", + TESTFILE, strerror(errno)); + return false; + } + + if (fstat(fd, &st1) != 0) { + printf("failure: utime [\n" + "fstat (1) failed - %s\n]\n", + strerror(errno)); + return false; + } + + u.actime = st1.st_atime + 300; + u.modtime = st1.st_mtime - 300; + if (utime(TESTFILE, &u) != 0) { + printf("failure: utime [\n" + "utime(&u) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st2) != 0) { + printf("failure: utime [\n" + "fstat (2) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (utime(TESTFILE, NULL) != 0) { + printf("failure: utime [\n" + "utime(NULL) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st3) != 0) { + printf("failure: utime [\n" + "fstat (3) failed - %s\n]\n", + strerror(errno)); + return false; + } + +#define CMP_VAL(a,c,b) do { \ + if (a c b) { \ + printf("failure: utime [\n" \ + "%s: %s(%d) %s %s(%d)\n]\n", \ + __location__, \ + #a, (int)a, #c, #b, (int)b); \ + return false; \ + } \ +} while(0) +#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b) +#define GREATER_VAL(a,b) CMP_VAL(a,<=,b) +#define LESSER_VAL(a,b) CMP_VAL(a,>=,b) + + EQUAL_VAL(st2.st_atime, st1.st_atime + 300); + EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); + LESSER_VAL(st3.st_atime, st2.st_atime); + GREATER_VAL(st3.st_mtime, st2.st_mtime); + +#undef CMP_VAL +#undef EQUAL_VAL +#undef GREATER_VAL +#undef LESSER_VAL + + unlink(TESTFILE); + printf("success: utime\n"); + return true; +} + +static int test_utimes(void) +{ + struct timeval tv[2]; + struct stat st1, st2; + int fd; + + printf("test: utimes\n"); + unlink(TESTFILE); + + fd = open(TESTFILE, O_RDWR|O_CREAT, 0600); + if (fd == -1) { + printf("failure: utimes [\n" + "creating '%s' failed - %s\n]\n", + TESTFILE, strerror(errno)); + return false; + } + + if (fstat(fd, &st1) != 0) { + printf("failure: utimes [\n" + "fstat (1) failed - %s\n]\n", + strerror(errno)); + return false; + } + + ZERO_STRUCT(tv); + tv[0].tv_sec = st1.st_atime + 300; + tv[1].tv_sec = st1.st_mtime - 300; + if (utimes(TESTFILE, tv) != 0) { + printf("failure: utimes [\n" + "utimes(tv) failed - %s\n]\n", + strerror(errno)); + return false; + } + + if (fstat(fd, &st2) != 0) { + printf("failure: utimes [\n" + "fstat (2) failed - %s\n]\n", + strerror(errno)); + return false; + } + +#define EQUAL_VAL(a,b) do { \ + if (a != b) { \ + printf("failure: utimes [\n" \ + "%s: %s(%d) != %s(%d)\n]\n", \ + __location__, \ + #a, (int)a, #b, (int)b); \ + return false; \ + } \ +} while(0) + + EQUAL_VAL(st2.st_atime, st1.st_atime + 300); + EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300); + +#undef EQUAL_VAL + + unlink(TESTFILE); + printf("success: utimes\n"); + return true; +} + struct torture_context; bool torture_local_replace(struct torture_context *ctx) { @@ -920,6 +1063,8 @@ bool torture_local_replace(struct torture_context *ctx) ret &= test_socketpair(); ret &= test_strptime(); ret &= test_getifaddrs(); + ret &= test_utime(); + ret &= test_utimes(); return ret; } -- cgit From a0c6043c34abe5451e5de55791fc274e113504af Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 16:50:19 +0200 Subject: libreplace: split out network checks into a AC_LIBREPLACE_NETWORK_CHECKS macro Note: moving it out of AC_LIBREPLACE_BROKEN_CHECKS will be the next step metze (This used to be commit 55a904b1d7aeca849d450e371b18afca5b0c6218) --- source4/lib/replace/libreplace.m4 | 65 +--------------------------- source4/lib/replace/libreplace_network.m4 | 71 +++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 63 deletions(-) create mode 100644 source4/lib/replace/libreplace_network.m4 (limited to 'source4/lib') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 8e17258918..1eba93792b 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -96,65 +96,10 @@ fi AC_CHECK_HEADERS(sys/syslog.h syslog.h) AC_CHECK_HEADERS(sys/time.h time.h) AC_CHECK_HEADERS(stdarg.h vararg.h) -AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) -AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) AC_CHECK_HEADERS(sys/sockio.h sys/un.h) AC_CHECK_HEADERS(sys/mount.h mntent.h) AC_CHECK_HEADERS(stropts.h) -dnl we need to check that net/if.h really can be used, to cope with hpux -dnl where including it always fails -AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ - AC_INCLUDES_DEFAULT - #if HAVE_SYS_SOCKET_H - # include - #endif - #include - int main(void) {return 0;}])], - [libreplace_cv_USABLE_NET_IF_H=yes], - [libreplace_cv_USABLE_NET_IF_H=no] - ) -]) -if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then - AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) -fi - -AC_HAVE_TYPE([socklen_t],[#include ]) -AC_HAVE_TYPE([sa_family_t],[#include ]) -AC_HAVE_TYPE([struct addrinfo], [#include ]) -AC_HAVE_TYPE([struct sockaddr], [#include ]) -AC_HAVE_TYPE([struct sockaddr_storage], [ -#include -#include -#include -]) -AC_HAVE_TYPE([struct sockaddr_in6], [ -#include -#include -#include -]) - -if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then -AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, - AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, - [ -#include -#include -#include - ]) - -if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then -AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, - AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, - [ -#include -#include -#include - ]) -fi -fi - AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) @@ -326,19 +271,12 @@ m4_include(getpass.m4) m4_include(strptime.m4) m4_include(win32.m4) m4_include(timegm.m4) -m4_include(socket.m4) -m4_include(inet_ntop.m4) -m4_include(inet_pton.m4) -m4_include(inet_aton.m4) -m4_include(inet_ntoa.m4) -m4_include(getaddrinfo.m4) m4_include(repdir.m4) -m4_include(getifaddrs.m4) -m4_include(socketpair.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) echo "LIBREPLACE_BROKEN_CHECKS: END" +AC_LIBREPLACE_NETWORK_CHECKS ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START, @@ -361,5 +299,6 @@ CFLAGS="$CFLAGS -I$libreplacedir" m4_include(libreplace_cc.m4) m4_include(libreplace_ld.m4) +m4_include(libreplace_network.m4) m4_include(libreplace_macros.m4) m4_include(autoconf-2.60.m4) diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4 new file mode 100644 index 0000000000..7702702799 --- /dev/null +++ b/source4/lib/replace/libreplace_network.m4 @@ -0,0 +1,71 @@ +AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS, +[ +echo "LIBREPLACE_NETWORK_CHECKS: START" + +AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h) +AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h) + +dnl we need to check that net/if.h really can be used, to cope with hpux +dnl where including it always fails +AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + AC_INCLUDES_DEFAULT + #if HAVE_SYS_SOCKET_H + # include + #endif + #include + int main(void) {return 0;}])], + [libreplace_cv_USABLE_NET_IF_H=yes], + [libreplace_cv_USABLE_NET_IF_H=no] + ) +]) +if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then + AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h) +fi + +AC_HAVE_TYPE([socklen_t],[#include ]) +AC_HAVE_TYPE([sa_family_t],[#include ]) +AC_HAVE_TYPE([struct addrinfo], [#include ]) +AC_HAVE_TYPE([struct sockaddr], [#include ]) +AC_HAVE_TYPE([struct sockaddr_storage], [ +#include +#include +#include +]) +AC_HAVE_TYPE([struct sockaddr_in6], [ +#include +#include +#include +]) + +if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.ss_family, + AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),, + [ +#include +#include +#include + ]) + +if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then +AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family, + AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),, + [ +#include +#include +#include + ]) +fi +fi + +m4_include(socket.m4) +m4_include(inet_ntop.m4) +m4_include(inet_pton.m4) +m4_include(inet_aton.m4) +m4_include(inet_ntoa.m4) +m4_include(getaddrinfo.m4) +m4_include(getifaddrs.m4) +m4_include(socketpair.m4) + +echo "LIBREPLACE_NETWORK_CHECKS: END" +]) dnl end AC_LIBREPLACE_NETWORK_CHECKS -- cgit From 63da424e8124a9def5d46f769804be661b059aab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 17:15:36 +0200 Subject: libreplace: use AC_LIBREPLACE_NETWORK_CHECKS only for samba metze (This used to be commit 3451b54bf7f5e37a589ec261d28c2a8b6f9788ed) --- source4/lib/replace/libreplace.m4 | 1 - source4/lib/replace/samba.m4 | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4 index 1eba93792b..2b33d97989 100644 --- a/source4/lib/replace/libreplace.m4 +++ b/source4/lib/replace/libreplace.m4 @@ -276,7 +276,6 @@ m4_include(repdir.m4) AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])]) echo "LIBREPLACE_BROKEN_CHECKS: END" -AC_LIBREPLACE_NETWORK_CHECKS ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START, diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4 index 7984ef31db..07c4d38887 100644 --- a/source4/lib/replace/samba.m4 +++ b/source4/lib/replace/samba.m4 @@ -1,4 +1,5 @@ AC_LIBREPLACE_BROKEN_CHECKS +AC_LIBREPLACE_NETWORK_CHECKS SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}]) SMB_ENABLE(LIBREPLACE_EXT) -- cgit From 10a208fc4f8de6fdd20e5906f9fc6915124f6f83 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 7 May 2008 17:38:41 +0200 Subject: libreplace: also use AC_LIBREPLACE_NETWORK_CHECKS for the standalone build metze (This used to be commit 04f4523ed032946b8f0e74ac6f7458010159e3bb) --- source4/lib/replace/configure.ac | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib') diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac index 02dc08bf72..81997e09b7 100644 --- a/source4/lib/replace/configure.ac +++ b/source4/lib/replace/configure.ac @@ -6,6 +6,7 @@ AC_CONFIG_HEADER(config.h) CFLAGS="$CFLAGS -I$srcdir" AC_LIBREPLACE_ALL_CHECKS +AC_LIBREPLACE_NETWORK_CHECKS if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wall" -- cgit From 4aba4d38c7cc1df4520df7f052d7d3c039597ed2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 May 2008 11:56:32 +0200 Subject: Fix link flags for ldb and tdb Python modules. (This used to be commit 787a32fdef9d761d64839f489cca0b0684f9a9fd) --- source4/lib/ldb/ldb.mk | 2 +- source4/lib/tdb/tdb.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index cc920178bc..58ce598d06 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -71,7 +71,7 @@ ldb_wrap.o: $(ldbdir)/ldb_wrap.c $(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` _ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o - $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) + $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflagsb` install-python:: build-python mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \ diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk index 0e53927366..c91b1289cb 100644 --- a/source4/lib/tdb/tdb.mk +++ b/source4/lib/tdb/tdb.mk @@ -39,7 +39,7 @@ tdb_wrap.o: $(tdbdir)/tdb_wrap.c $(CC) $(PICFLAG) -c $(tdbdir)/tdb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` _tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o - $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --libs` + $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --ldflags` install:: installdirs installbin installheaders installlibs \ $(PYTHON_INSTALL_TARGET) -- cgit From c68589a5dcefc2cd337449d343019271192fc11a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 May 2008 12:40:56 +0200 Subject: Fix typo. (This used to be commit 1def988ef28de85b3f97172bdbf935a4fec4dec3) --- source4/lib/ldb/ldb.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 58ce598d06..df11e9d2ab 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -71,7 +71,7 @@ ldb_wrap.o: $(ldbdir)/ldb_wrap.c $(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags` _ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o - $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflagsb` + $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags` install-python:: build-python mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \ -- cgit From b3e1d69dcd58a72851b2efefd83ade377c9d2e85 Mon Sep 17 00:00:00 2001 From: William Jojo Date: Thu, 8 May 2008 12:41:57 +0200 Subject: Add undefined symbol flag for AIX. (This used to be commit dabdf24e86f038e3afc67532fa5bf60a37992161) --- source4/lib/replace/libreplace_ld.m4 | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index f0d10c1e3e..0d0356055c 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -270,6 +270,10 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], *darwin*) LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup" ;; + *aix*) + LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry" + ;; + ; esac AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG) -- cgit From ca6ac11b46a75bf02cf873c6aedb4f85af227168 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 8 May 2008 13:43:45 +0200 Subject: Fix typo. (This used to be commit bd089818a3182698dfe85039c1b2e22d8c2835bb) --- source4/lib/replace/libreplace_ld.m4 | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4 index 0d0356055c..9995d69bbc 100644 --- a/source4/lib/replace/libreplace_ld.m4 +++ b/source4/lib/replace/libreplace_ld.m4 @@ -273,7 +273,6 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG], *aix*) LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry" ;; - ; esac AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG) -- cgit From d0096e90ba9d8aa6b339022bac194e57ae0a2b7a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 10 May 2008 00:46:25 +0200 Subject: Fix installation of pidl perl files, torture pc file. (This used to be commit 32da606e3759026c2744f853cd8948333ed0579c) --- source4/lib/torture/config.mk | 3 +++ source4/lib/torture/torture.pc.in | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 source4/lib/torture/torture.pc.in (limited to 'source4/lib') diff --git a/source4/lib/torture/config.mk b/source4/lib/torture/config.mk index e981ee0c99..15c64786c5 100644 --- a/source4/lib/torture/config.mk +++ b/source4/lib/torture/config.mk @@ -5,6 +5,9 @@ PUBLIC_DEPENDENCIES = \ LIBSAMBA-UTIL \ LIBTALLOC +TORTURE_VERSION = 0.0.1 +TORTURE_SO_VERSION = 0 + PC_FILES += lib/torture/torture.pc torture_OBJ_FILES = $(addprefix lib/torture/, torture.o) diff --git a/source4/lib/torture/torture.pc.in b/source4/lib/torture/torture.pc.in new file mode 100644 index 0000000000..6582816cb5 --- /dev/null +++ b/source4/lib/torture/torture.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +modulesdir=${prefix}/modules/torture + +Name: torture +Description: Samba torture (test) suite +Requires: talloc +Version: 0.0.1 +Libs: -L${libdir} -ltorture +Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1 -- cgit From bc4eacb5d89ca8dca123e2d6bd6eba47ed93b771 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 10 May 2008 14:26:08 +0200 Subject: Fix case. (This used to be commit a90971ea0c43ce3b42b95aef5973139576b51959) --- source4/lib/torture/config.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/torture/config.mk b/source4/lib/torture/config.mk index 15c64786c5..638f0d940c 100644 --- a/source4/lib/torture/config.mk +++ b/source4/lib/torture/config.mk @@ -5,8 +5,8 @@ PUBLIC_DEPENDENCIES = \ LIBSAMBA-UTIL \ LIBTALLOC -TORTURE_VERSION = 0.0.1 -TORTURE_SO_VERSION = 0 +torture_VERSION = 0.0.1 +torture_SO_VERSION = 0 PC_FILES += lib/torture/torture.pc torture_OBJ_FILES = $(addprefix lib/torture/, torture.o) -- cgit