summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
AgeCommit message (Collapse)Author
2014-07-27parse_boolean: require exact matchesAnsgar Burchardt
Require exact matches in all cases instead of treating strings starting with 't' ('f') as true (false). This is required for config_parse_protect_system to parse ProtectSystem=full correctly: it uses parse_boolean and only tries a more specific parsing function if that did not return a valid result. Thus "full" was treated as "false" before.
2014-07-11util: fix has cc check and add testZbigniew Jędrzejewski-Szmek
2014-07-02util: when unescaping strings, don't allow smuggling in of additional NUL bytesLennart Poettering
Better safe than sorry.
2014-06-19tests: add tests to test-utilRonny Chevalier
add tests for: - filename_is_safe - ascii_strlower - files_same - is_valid_documentation_url - file_in_same_dir - endswith - close_nointr - unlink_noerrno - readlink_and_make_absolute - read_one_char - ignore_signals - strshorten
2014-06-16tests: unlink temp file used in testRonny Chevalier
2014-05-15Remove unnecessary casts in printfsZbigniew Jędrzejewski-Szmek
No functional change expected :)
2014-05-13shared: add ALIGN_POWER2 macroDavid Herrmann
Sounds easy, turns out to be horrible to implement: ALIGN_POWER2 returns the next higher power of 2. clz(0) is undefined, same is true for left-shift-overflows, yey, C rocks!
2014-03-19util: add new FOREACH_STRING() macro as syntactic sugar to iterate through a ↵Lennart Poettering
number of fixed strings
2014-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering
safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
2014-03-14timedated: use builtins for integer log and expZbigniew Jędrzejewski-Szmek
2014-03-14util: add hexdump() call to create pretty hexdumps of dataLennart Poettering
This is very useful when debugging sd-bus to look at messages.
2014-03-12macro: make sure we can use IN_SET() also with complex function calls as ↵Lennart Poettering
first argument
2014-03-02Disallow sizes with increasing unit sizeZbigniew Jędrzejewski-Szmek
Things like 3B4T, 4B50B, 400 100 (meaning 4*1024**4+3, 54, and 500, respectively) are now disallowed. It is necessary to say 4T3B, 54B, 500 instead. I think this was confusing and error prone. As a special form, 400B 100 is allowed, i.e. "B" suffix is treated as different from "", although they mean the same thing.
2014-03-02Allow fractional parts in disk sizesZbigniew Jędrzejewski-Szmek
It seems natural to be able to say SystemMaxUsage=1.5G. https://bugzilla.redhat.com/show_bug.cgi?id=1047568
2014-02-23core: clean up some confusing regarding SI decimal and IEC binary suffixes ↵Lennart Poettering
for sizes According to Wikipedia it is customary to specify hardware metrics and transfer speeds to the basis 1000 (SI decimal), while software metrics and physical volatile memory (RAM) sizes to the basis 1024 (IEC binary). So far we specified everything in IEC, let's fix that and be more true to what's otherwise customary. Since we don't want to parse "Mi" instead of "M" we document each time what the context used is.
2014-02-19make gcc shut upLennart Poettering
If -flto is used then gcc will generate a lot more warnings than before, among them a number of use-without-initialization warnings. Most of them without are false positives, but let's make them go away, because it doesn't really matter.
2014-02-11util: drop parse_user_at_host() since its unused nowLennart Poettering
2014-01-28Get rid of write_safeZbigniew Jędrzejewski-Szmek
Current glibc implementation is safe. Kernel does this atomically, and write is actually implemented through writev. So if write is async-signal-safe, than writev pretty much must be too.
2014-01-28always use the same code for creating temporary filesLennart Poettering
Let's unify our code here, and also always specifiy O_CLOEXEC.
2014-01-27journal: guarantee async-signal-safety in sd_journald_sendvZbigniew Jędrzejewski-Szmek
signal(7) provides a list of functions which may be called from a signal handler. Other functions, which only call those functions and don't access global memory and are reentrant are also safe. sd_j_sendv was mostly OK, but would call mkostemp and writev in a fallback path, which are unsafe. Being able to call sd_j_sendv in a async-signal-safe way is important because it allows it be used in signal handlers. Safety is achieved by replacing mkostemp with open(O_TMPFILE) and an open-coded writev replacement which uses write. Unfortunately, O_TMPFILE is only available on kernels >= 3.11. When O_TMPFILE is unavailable, an open-coded mkostemp is used. https://bugzilla.gnome.org/show_bug.cgi?id=722889
2013-12-02macro: add a macro to test whether a value is in a specified listLennart Poettering
Introduce IN_SET() macro to nicely check whether a value a is one of a few listed values. This makes writing this: if (a == 1 || a == 7 || a == 8 || a == 9) nicer, by allowing this: if (IN_SET(a, 1, 7, 8, 9)) This is particularly useful for state machine enums.
2013-11-21bus: add API calls to escape string components of objects pathsLennart Poettering
2013-10-09tests: fix some memory leaks in testsLennart Poettering
2013-09-29Fix buffer overrun when enumerating filesZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=69887 Based-on-a-patch-by: Hans Petter Jansson <hpj@copyleft.no>
2013-09-17Use udev_encode_string in fstab_node_to_udev_nodeDave Reisner
Resolves a longstanding bug which caused this function to wrongly handle (escape) valid utf8 characters.
2013-08-22test: Make testing work on systems without or old systemdHolger Hans Peter Freyther
* Introduce a macro to conditionally execute tests. This avoids skipping the entire test if some parts require systemd * Skip the journal tests when no /etc/machine-id is present * Change test-catalog to load the catalog from the source directory of systemd. * /proc/PID/comm got introduced in v2.6.33 but travis is still using v2.6.32. * Enable make check and make distcheck on the travis build * Use -D"CATALOG_DIR=STR($(abs_top_srcdir)/catalog)" as a STRINGIY would result in the path '/home/ich/source/linux' to be expanded to '/home/ich/source/1' as linux is defined to 1.
2013-08-15tests: fix indentationThomas Hindoe Paaboel Andersen
2013-07-18util: add split_pair() for splitting foo=bar stringsLennart Poettering
2013-07-16tests: add more tests for shared/util.cThomas Hindoe Paaboel Andersen
2013-06-10Properly check for overflow in offsetsZbigniew Jędrzejewski-Szmek
2013-04-25Use attribute(unused) in PROTECT_ERRNOZbigniew Jędrzejewski-Szmek
clang emits warnings about unused attribute _saved_errno_, which drown out other—potentially useful—warnings. gcc documentation is not exactly verbose about the effects of __attribute__((unused)) on variables, but let's assume that it works if the unit test passes.
2013-04-25util: rework safe_atod() to be locale-independentLennart Poettering
This adds some syntactic sugar with a macro RUN_WITH_LOCALE() that reset the thread-specific locale temporarily.
2013-04-16util: make generation of profcs PID paths nicerLennart Poettering
2013-04-05journal: u64log2 can be expressed just as __builtin_clzll(n) ^ 63UCristian Rodríguez
2013-03-22util: be more picky when validating hostnamesLennart Poettering
No longer allow dots at the beginning or end of host names, Or double dots. https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1152187/comments/14
2013-03-07test-util: add more testsThomas Hindoe Paaboel Andersen
Improve test coverage a bit with tests for close_many strappend (to cover all ways through strnappend)
2013-03-05util: properly escape corner cases in bus_path_escape(), tooLennart Poettering
This follows the suggestions from: http://lists.freedesktop.org/archives/systemd-devel/2013-March/009363.html
2013-02-26test-util.c: added hexchar, unhexchar, octchar, unoctchar, decchar, ↵Daniel Buch
undecchar tests
2013-02-25tests: add a few more tests to test-util.cThomas Hindoe Paaboel Andersen
Add asserts on the resutls in FOREACH_WORD_QUOTED Added tests for: FOREACH_WORD strstrip delete_chars in_charset
2013-02-20tests: more tests for util.cThomas Hindoe Paaboel Andersen
tests for: test_parse_pid test_parse_uid test_safe_atolli test_safe_atod
2013-02-18tests: add test of memdup_multiplyThomas Hindoe Paaboel Andersen
2013-02-11tests: more testsThomas Hindoe Paaboel Andersen
tests for: parse_boolean env_name_is_valid Also convert assert to assert_se to make sure they are run even with optimization. (see commit 9b5d6bd909855543cba75a4469bff6f82845cf0d)
2013-02-06test: add a few tests and tidy upThomas Hindoe Paaboel Andersen
adds test of: strv_find strv_find_prefix strv_overlap strv_sort streq_ptr first_word Splits tests of util.c into own file to avoid clutter as we add more. Removed a few prints and uses _cleanup_free_ to make the tests more focused.