1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

62 Commits

Author SHA1 Message Date
Martin Schwenke
92cfd1e9b8 torture: Add tests for trim_string()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Ralph Boehme <slow@samba.org>
2016-06-20 00:47:30 +02:00
Douglas Bagnall
407c812b2a util/tests: add test for BINARY_ARRAY_SEARCH_V macro
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-09 10:32:16 +01:00
Douglas Bagnall
5235f1facf util/binsearch: macro for greater than or equal search
Sometimes you want to find the place where an item would be in a
sorted list, whether or not it is actually there.

The BINARY_ARRAY_SEARCH_GTE macro takes an extra 'next' pointer
argument over the other binsearch macros. This will end up pointing to
the next element in the case where there is not an exact match, or
NULL when there is. That is, searching the list

     { 2, 3, 4, 4, 9}

with a standard integer compare should give the following results:

search term    *result    *next
         1      -          2
         3      3          -
         4      4 [1]      -
         7      -          9
         9      9          -
        10      -          - [2]

Notes
[1] There are two fours, but you will always get the first one.
[2] The both NULL case means the search term is beyond the last list
item.

You can safely use the same pointer for both 'result' and 'next', if
you don't care to distinguish between the 'greater-than' and 'equals'
cases.

There is a torture test for this.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-09 10:32:16 +01:00
Martin Schwenke
e318babace lib/util: Add strv_util.[ch] containing new function strv_split()
strv_split() adds to a strv by splitting a string on separators.

Tests included.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2016-03-01 05:43:19 +01:00
Martin Schwenke
7105e171f0 lib/util: Add tests for strv_addn()
Also some other minor test cleanups.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Feb 29 15:18:17 CET 2016 on sn-devel-144
2016-02-29 15:18:17 +01:00
Martin Schwenke
f3ea162488 lib/util: Add tests for strv
These are blackbox tests against most of the API.

It would be possible to write tests that check the internals of the
strv are as expected but that probably doesn't add much value.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-02-26 19:27:08 +01:00
Michael Adam
2fd63ec80a dlist: remove unneeded type argument from DLIST_CONCATENATE()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-02-06 21:48:18 +01:00
Michael Adam
d6f5fc8c2d dlist: remove unneeded argument from DLIST_DEMOTE()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-02-06 21:48:17 +01:00
Michael Adam
476672b647 dlist: remove unneeded type argument from DLIST_ADD_END()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-02-06 21:48:17 +01:00
Volker Lendecke
44c56fc667 asn1: Remove a reference to asn1_data internals
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-01-06 00:54:18 +01:00
Volker Lendecke
e73ccc06ef Rely on /dev/urandom
This removes quite a bit of code. All reasonable systems have /dev/urandom
these days. Linux, Solaris and the BSDs do.  In case we find a system
without /dev/urandom, we will have to go hunting in other libraries.

The main reason for this is speed: On Ubuntu 14.04 doing direct reads from
/dev/urandom is 2-3 times faster than our md4 based code. On virtualized
FreeBSD 10 the difference is even larger.

My first approach was to use fopen/fread. It was even faster, but less
than twice as fast. So I thought we could save the additional complexity
when having to deal with throwing away buffers when forking and the
additional memory footprint per process.

With this simple generate_random_buffer it will be easier to adapt new
syscalls to get randomness.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Oct 13 04:25:39 CEST 2015 on sn-devel-104
2015-10-13 04:25:38 +02:00
Volker Lendecke
5380f7b636 lib: Add a little tool to perftest generate_random_buffer()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-10-13 01:23:07 +02:00
Volker Lendecke
78d7512db9 lib: Remove unused parmlist code
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-08-21 11:43:04 +02:00
Volker Lendecke
0f91e4e18d lib: Fix a few CIDs for Resource Leak
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-04-21 19:37:16 +02:00
Stefan Metzmacher
3f0c7e8794 lib/util/tests: avoid some compiler warnings
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-14 23:27:04 +01:00
Jeremy Allison
612b74296c lib: util: asn1 tests. Check every asn1 return.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-26 00:51:16 +02:00
Stefan Metzmacher
8ba775b0a3 lib/util/tests: add missing #include "torture/local/proto.h"
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2014-04-02 09:03:44 +02:00
Stefan Metzmacher
65f2bba559 lib/util: improve check_password_quality() to handle utf8
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-04 17:14:22 +01:00
Andrew Bartlett
530e4cac2e s3-param Remove 'time offset' from smb.conf
This strange parameter is apparently very rarely used, and it seems to
me that on modern networks, if clients don't have correct clocks and
DST offsets, that many other things (Kerberos) start to fail pretty
quickly, and time and DST tables tend to be internet delivered anyway.

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Sat Jun 11 03:54:45 CEST 2011 on sn-devel-104
2011-06-11 03:54:44 +02:00
Andrew Bartlett
ede98c0e51 lib/util Add Volker's asn1_Integer test into code that runs in 'make test'
The comfychair test harness isn't hooked up, and with the current
infrustructure C code is better tested directly here.

Andrew Bartlett
2011-05-24 12:48:00 -07:00
Jeremy Allison
017e0c8d95 Fix simple uses of safe_strcpy -> strlcpy. Easy ones where we just remove -1. 2011-05-04 12:12:13 -07:00
Andrew Bartlett
d01f318179 s4: fix arguments to safe_strcpy()
Found by the s3-derivied safe_strcpy() macro.

Andrew Bartlett
2011-05-03 07:37:07 +02:00
Stefan Metzmacher
c9e6bf047d lib/util: add tests for anonymous_shared_allocate/free()
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Thu Jan 20 06:25:03 CET 2011 on sn-devel-104
2011-01-20 06:25:03 +01:00
Matthias Dieter Wallnöfer
3b591caed0 lib/util/asn1.c - remove the "const" specifier from OID
There is no reason to have it "const" since it's an allocated thing.
2010-12-21 15:10:37 +11:00
Jelmer Vernooij
35fbc7bbda s4-smbtorture: Make test names lowercase and dot-separated.
This is consistent with the test names used by selftest, should
make the names less confusing and easier to integrate with other tools.

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Dec 11 04:16:13 CET 2010 on sn-devel-104
2010-12-11 04:16:13 +01:00
Matthias Dieter Wallnöfer
bd3e5804a4 Revert "lib/util:tests/time.c - "test_timestring" - fix it on Solaris"
This reverts commit 654e0102dd.
This should better be handled by the replace library.

Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date: Mon Dec  6 12:17:31 CET 2010 on sn-devel-104
2010-12-06 12:17:31 +01:00
Matthias Dieter Wallnöfer
654e0102dd lib/util:tests/time.c - "test_timestring" - fix it on Solaris
Solaris returns "Thu Jan 01" and not "Thu Jan  1" - therefore proof for
both.

Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date: Sun Dec  5 23:09:13 CET 2010 on sn-devel-104
2010-12-05 23:09:13 +01:00
Kamen Mazdrashki
14cb61da8f asn1_tests: Implement negative unit-tests for ber_write_OID_String() 2010-10-22 01:48:58 +03:00
Kamen Mazdrashki
099b0057be asn1_tests.c: Make test data static const 2010-10-20 13:12:17 +00:00
Jelmer Vernooij
4c681f760f strlist: Make test names unique. 2010-09-21 22:54:33 -07:00
Andrew Tridgell
6b266b85cf s4-loadparm: 2nd half of lp_ to lpcfg_ conversion
this converts all callers that use the Samba4 loadparm lp_ calling
convention to use the lpcfg_ prefix.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2010-07-16 18:24:27 +10:00
Brad Hards
dd89dc2c31 Spelling fixes for libutil
Signed-off-by: Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
2010-02-22 21:45:35 +01:00
Andrew Tridgell
91cb7b7c60 test:local added LOCAL-DLINKLIST testsuite
(cherry picked from commit 95a5bee2c30a67a35604b0456ab7836f6dc67702)
2010-02-10 15:55:34 -08:00
Matthias Dieter Wallnöfer
94c33bdd72 util/strlist: Fix up "const" warnings in the string list and test code
This work I did using suggestions by Jelmer.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-11-20 16:50:47 +01:00
Kamen Mazdrashki
b7839b73b1 util: str_list_unique_2() test implementation
Difference with previous test for str_list_unique() is
that this test allows number of elements and number
of duplicates to be supplied on command line using
--option="list_unique:count=47"
--option="list_unique:dups=7"
2009-11-13 23:19:06 +11:00
Andrew Bartlett
fd5174e88c lib/util Split data_blob_hex_string() into upper and lower
Rather than have a repeat of the bugs we found at the plugfest where
hexidecimal strings must be in upper or lower case in particular
places, ensure that each caller chooses which case they want.

This reverts most of the callers back to upper case, as things were
before tridge's patch.  The critical call in the extended DN code is
of course handled in lower case.

Andrew Bartlett
2009-11-12 16:34:01 +11:00
Kamen Mazdrashki
f11cdc19d1 s4/asn1: Use explicite TALLOC_CTX in ber_write_OID functions 2009-10-16 12:54:13 +03:00
Karolin Seeger
fc2604ed26 asn1_tests: Fix typo in comment.
Karolin
2009-10-09 11:27:06 +02:00
Kamen Mazdrashki
a96c8c2355 s4/asn1: local TALLOC_CTX should be child of torture_context 2009-10-01 23:13:00 +02:00
Kamen Mazdrashki
a51571bf41 s4/asn1: fixed typo in torture messages 2009-10-01 23:13:00 +02:00
Kamen Mazdrashki
97e7f48f75 s4/asn1: Added test for ber_read_partial_OID_String() 2009-10-01 23:13:00 +02:00
Kamen Mazdrashki
5021301a0e s4/asn1: Added test for ber_read_OID_String() 2009-10-01 23:12:59 +02:00
Kamen Mazdrashki
681064e66e s4/asn1: Added test for ber_write_partial_OID_String() 2009-10-01 23:12:59 +02:00
Kamen Mazdrashki
3c3ef94ab3 s4/asn1: Added test for ber_write_OID_String() 2009-10-01 23:12:59 +02:00
Kamen Mazdrashki
bd5343924f s4/asn1: Added torture suite for ASN1 2009-10-01 23:12:59 +02:00
Andrew Kroeger
c5dba4a82e s4:torture: data_blob_hex_string() output is now lowercase.
Based on the change in commit fb84edabbe, these
tests needs to expect lowercase output.
2009-09-30 16:02:14 +02:00
Jelmer Vernooij
d9ada600cc parmlist: Add more tests. 2009-09-27 17:37:53 +02:00
Jelmer Vernooij
db55ea08bc parmlist: Add basic tests for test_get_int(). 2009-09-27 14:39:58 +02:00
Andrew Kroeger
a32f4dd3cf util:tests: Correct time tests for negative UTC offsets.
All:

Please find attached a patch to fix the timestring and http_timestring
tests on hosts that have a negative UTC offset (west of the Prime Meridian).

Sincerely,
Andrew Kroeger

>From 8a8ca35edccf64aa98f2f3ae1469c4c27db8215e Mon Sep 17 00:00:00 2001
From: Andrew Kroeger <andrew@id10ts.net>
Date: Fri, 4 Sep 2009 01:31:50 -0500
Subject: [PATCH] util:tests: Correct time tests for negative UTC offsets.

The timestring and http_timestring tests were failing on hosts with negative
offsets from UTC.  Due to the timezone offset, the returned values were back in
the year 1969 (before the epoch) and did not match the test patterns.

The correction computes the offset from UTC, and if it is negative that offset
is added onto the value given to the timestring() and http_timestring() calls so
that the returned values fall on 01-Jan-1970 and match the test pattern.
2009-09-05 10:06:29 +10:00
Matthieu Patou
a817cff5a0 Fix broken password quality check
This fixes broken password tests when the passwords contain non ASCII characters
(e.g. accentuated chars like ('e, `e, ...)
2009-07-19 16:00:19 +02:00