summaryrefslogtreecommitdiff
path: root/lib/util/tests/util.c
AgeCommit message (Collapse)AuthorFilesLines
2022-06-09lib/util: Add test of mem_equal_const_time()Joseph Sutton1-0/+22
Ensure that it gives the correct results for comparing two memory regions. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-08-03lib: relicense smb_strtoul(l) under LGPLv3Ralph Boehme1-0/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Aug 3 22:21:04 UTC 2020 on sn-devel-184
2019-06-30tests-util: Adding test to verify "allow no conversion" flagSwen Schillig1-0/+33
The internal string conversion routines smb_strtoul(l) return an error if the provided string could not be converted to an integer. This can be the case if the string is empty or if it starts with non-numeric characters which cannot be converted. The standard C library, however, does allow this and simply returns 0 as the converted value. If this behaviour is wanted, it can be enabled by using the "SMB_STR_ALLOW_NO_CONVERSION" flag. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Sun Jun 30 12:47:24 UTC 2019 on sn-devel-184
2019-06-30tests-util: Adding test to verify "full-string-conversion" flagSwen Schillig1-0/+28
The standard string to integer conversion routines stop at the first character which cannot be converted to a number. However, if such a character is found, it is not considered an error. With the flag "SMB_STR_FULL_STR_CONV" enabled, an error will be returned if the string could not be converted entirely. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30tests-util: Adding test to verify "allow-negative" flagSwen Schillig1-0/+38
The standard string to integer conversion routines allow strings with a leading "-" to indicate a negative number. However, the returned value is always an unsigned value representing the bit-pattern of this negative value. Typically, this behaviour is NOT wanted and therefore the standard behavior of the internal smb_strtoul(l) return an erros in such situations. It can be enabled though by using the flag SMB_STR_ALLOW_NEGATIVE. This test verifies the correct processing. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30lib: Update all consumers of strtoul_err(), strtoull_err() to new APISwen Schillig1-36/+36
Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30tests-util: Adding test to verify "no-conversion" detectionSwen Schillig1-0/+28
The standard string to integer conversion routines return zero if a string was to be converted which did not reflect a number. It is not flag'ed as an error. The wrapper functions strtoul_err() and strtoull_err() are expected to exactly do this. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30tests-util: Adding test to verify negative "number" detectionSwen Schillig1-0/+37
Verify that a string representing a negative number is throwing an error. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30tests-util: Adding strtoul(l)_err() test leaving errno untouchedSwen Schillig1-0/+29
The wrapper functions strtoul_err() and strtoull_err() trigger other functions/routines which modify errno. However, callers of those wrapper functions expect errno to be unchanged. This test verifies the expectation. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2018-09-15torture: Remove unnecesssary #include <fcntl.h>Christof Schmitt1-1/+0
This is now provided through system/filesys.h. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-31lib: Fix the build on FreeBSDVolker Lendecke1-0/+1
FreeBSD needs to explicitly #include <unistd.h> for geteuid() and close() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Aug 31 18:42:31 CEST 2018 on sn-devel-144
2018-08-30torture: Add test for directory_create_or_existChristof Schmitt1-0/+60
Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Thu Aug 30 21:19:31 CEST 2018 on sn-devel-144
2016-06-20torture: Add tests for trim_string()Martin Schwenke1-0/+376
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Ralph Boehme <slow@samba.org>