summaryrefslogtreecommitdiff
path: root/src/test/test-strv.c
AgeCommit message (Collapse)Author
2016-04-13test-strv: add a test that extending empty strv works as expectedZbigniew Jędrzejewski-Szmek
Just making sure :)
2016-03-03tests: move strv related tests to test-strv.cRonny Chevalier
2016-02-13basic/strv: fix strv_join for first empty argumentZbigniew Jędrzejewski-Szmek
Empty strings were ignored in strv_join, but only if they were at the beginning of the string. Empty strings after at least one non-empty item were treated normally. Previously: {"x"} → "x" {"x", ""} → "x" {"x", "", ""} → "x::" {""} → "" {"", ""} → "" {"", "", ""} → "" {"", "x"} → "x" {"", "x", ""} → "x:" Now: {"x"} → "x" {"x", ""} → "x" {"x", "", ""} → "x::" {""} → "" {"", ""} → ":" {"", "", ""} → "::" {"", "x"} → ":x" {"", "x", ""} → ":x:"
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-10-07ask-password: add support for caching passwords in the kernel keyringLennart Poettering
This adds support for caching harddisk passwords in the kernel keyring if it is available, thus supporting caching without Plymouth being around. This is also useful for hooking up "gdm-auto-login" with the collected boot-time harddisk password, in order to support gnome keyring passphrase unlocking via the HDD password, if it is the same. Any passwords added to the kernel keyring this way have a timeout of 2.5min at which time they are purged from the kernel.
2015-10-06core: add support for naming file descriptors passed using socket activationLennart Poettering
This adds support for naming file descriptors passed using socket activation. The names are passed in a new $LISTEN_FDNAMES= environment variable, that matches the existign $LISTEN_FDS= one and contains a colon-separated list of names. This also adds support for naming fds submitted to the per-service fd store using FDNAME= in the sd_notify() message. This also adds a new FileDescriptorName= setting for socket unit files to set the name for fds created by socket units. This also adds a new call sd_listen_fds_with_names(), that is similar to sd_listen_fds(), but also returns the names of the fds. systemd-activate gained the new --fdname= switch to specify a name for testing socket activation. This is based on #1247 by Maciej Wereski. Fixes #1247.
2015-09-29systemctl: move strv_skip_first() out of systemctl.cLennart Poettering
Make it generic, call it strv_skip() and move it to strv.[ch]
2015-08-07strv: Add strv_shell_escapeRichard Maw
This modifies the strv in-place, replacing strings with their escaped version. It's mostly just a convenience function for when you need to join a strv together because it's passed as a string to something, and the separator needs escaping.
2015-08-07strv: convert strv_split_quotes into a generic strv_split_extractRichard Maw
strv_split_extract is to strv_split_quotes as extract_first_word was to unquote_first_word. Now there's extract_first_word for extracting a single argument, extract_many_words for extracting a bounded number of arguments, and strv_split_extract for extracting an arbitrary number of arguments.
2015-08-06tree-wide: fix indentationThomas Hindoe Paaboel Andersen
2015-03-26util: rework word parsing and c unescaping codeLennart Poettering
When parsing words from input files, optionally automatically unescape the passed strings, controllable via a new flags parameter. Make use of this in tmpfiles, and port everything else over, too. This improves parsing quite a bit, since we no longer have to process the same string multiple times with different calls, where an earlier call might corrupt the input for a later call.
2014-12-19strv: ass new strv_is_uniq() and strv_reverse() callsLennart Poettering
2014-12-18Treat a trailing backslash as an errorZbigniew Jędrzejewski-Szmek
Commit a2a5291b3f5 changed the parser to reject unfinished quoted strings. Unfortunately it introduced an error where a trailing backslash would case an infinite loop. Of course this must fixed, but the question is what to to instead. Allowing trailing backslashes and treating them as normal characters would be one option, but this seems suboptimal. First, there would be inconsistency between handling of quoting and of backslashes. Second, a trailing backslash is most likely an error, at it seems better to point it out to the user than to try to continue. Updated rules: ExecStart=/bin/echo \\ → OK, prints a backslash ExecStart=/bin/echo \ → error ExecStart=/bin/echo "x → error ExecStart=/bin/echo "x"y → error
2014-12-18test-strv: use STRV_MAKEZbigniew Jędrzejewski-Szmek
2014-12-11test-strv: add test for strv_equalRonny Chevalier
2014-12-03strv: add calls to add two entries to an strv at onceLennart Poettering
2014-11-10strv: rework strv_split_quoted() to use unquote_first_word()Lennart Poettering
This should make the unquoting scheme a bit less naive.
2014-10-31tests: add tests for strv.cRonny Chevalier
add tests for: - strv_find_startswith - strv_push_prepend - strv_consume_prepend
2014-10-04test: only use assert_seThomas Hindoe Paaboel Andersen
The asserts used in the tests should never be allowed to be optimized away
2014-07-31Properly report invalid quoted stringsZbigniew Jędrzejewski-Szmek
$ systemd-analyze verify trailing-g.service [./trailing-g.service:2] Trailing garbage, ignoring. trailing-g.service lacks ExecStart setting. Refusing. Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument. Failed to create trailing-g.service/start: Invalid argument
2014-07-31Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek
String which ended in an unfinished quote were accepted, potentially with bad memory accesses. Reject anything which ends in a unfished quote, or contains non-whitespace characters right after the closing quote. _FOREACH_WORD now returns the invalid character in *state. But this return value is not checked anywhere yet. Also, make 'word' and 'state' variables const pointers, and rename 'w' to 'word' in various places. Things are easier to read if the same name is used consistently. mbiebl_> am I correct that something like this doesn't work mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"' mbiebl_> systemd seems to strip of the quotes mbiebl_> systemctl status shows mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint mbiebl_> which is pretty weird
2014-07-31test-strv: add test which shows access to random memoryZbigniew Jędrzejewski-Szmek
2014-06-19tests: add tests for strv_extendfRonny Chevalier
2014-01-05strv: multiple cleanupsSimon Peeters
- turn strv_merge into strv_extend_strv. appending strv b to the end of strv a instead of creating a new strv - strv_append: remove in favor of strv_extend and strv_push. - strv_remove: write slightly more elegant - strv_remove_prefix: remove unused function - strv_overlap: use strv_contains - strv_printf: STRV_FOREACH handles NULL correctly
2013-12-12scan-build: silence some warningsThomas Hindoe Paaboel Andersen
test-fileio/test-strv: Use the streq_ptr to make build-scan not worry about passing in a null to a nonnull function. test-dhcp-option: Prevent a theoretical null pointer dereference
2013-11-28util: fix handling of trailing whitespace in split_quoted()Lennart Poettering
Inspired by a patch by Lukas Nykryn.
2013-11-07test-strv: add strv_split, strv_split_newline, strv_remove_prefixDaniel Buch
2013-10-29strv: introduce new STRV_MAKE and STRV_MAKE_EMPTY macros to create string ↵Lennart Poettering
arrays nicely on the fly
2013-10-29strv: introduce new strv_from_stdarg_alloca() macro to generate a string ↵Lennart Poettering
array from stdarg function parameters This allows us to turn lists of strings passed in easily into string arrays without having to allocate memory.
2013-10-27test-strv.c: added STRV_FOREACH and STRV_FOREACH_BACKWARDSDaniel Buch
2013-09-17tmpfiles: support simple specifier expansion for specified pathsLennart Poettering
2013-09-17specifier: rework specifier calls to return proper error messageLennart Poettering
Previously the specifier calls could only indicate OOM by returning NULL. With this change they will return negative errno-style error codes like everything else.
2013-09-09systemd-run: properly escape argumentsZbigniew Jędrzejewski-Szmek
Spaces, quotes, and such, were not properly escaped. We should write them like we read them. https://bugs.freedesktop.org/show_bug.cgi?id=67971
2013-04-05test-strv: do not declare table to be sorted constZbigniew Jędrzejewski-Szmek
Segmentation fault under clang.
2013-03-18test-strv.c: test STRV_FOREACH_PAIR macroDaniel Buch
2013-02-18test-strv.c: ported test_specifier_printf() to _cleanup_free_ + assert_se + ↵Daniel Buch
cleanup
2013-02-18test-strv.c: added OOM check for current testsDaniel Buch
New OOM check patch: I do assert_se() before variable is used to do correct check.
2013-02-18test-strv.c: added strv_split_nulstr() testDaniel Buch
2013-02-13test-strv.c: Changed assert() to assert_se()Daniel Buch
test-strv.c: Indent fix
2013-02-13test-strv.c: added strv_append testDaniel Buch
2013-02-13test-strv.c: added strv_merge_concat testDaniel Buch
2013-02-13test-strv.c: added strv_merge testDaniel Buch
2013-02-07tests: move strv_parse_nulstr to test-strv, and actually test itThomas Hindoe Paaboel Andersen
The test was originally added with this commit message: "ask-password: supported plymouth cached passwords"
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.
2013-01-30test-strv.c: test strv_join addedDaniel Buch
2013-01-30test-strv.c: Split tests into seperate functionsDaniel Buch
test-strv.c: Leaves main clean for additional tests
2012-04-12test: test tools should still be in the src/ directoryLennart Poettering