summaryrefslogtreecommitdiff
path: root/src/test/test-fileio.c
AgeCommit message (Collapse)Author
2016-03-03tests: move fileio related tests to test-fileio.cRonny Chevalier
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-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-11-13util-lib: optionally, when writing a string to a file, verify string on failureLennart Poettering
With this change, the idiom: r = write_string_file(p, buf, 0); if (r < 0) { if (verify_one_line_file(p, buf) > 0) r = 0; } gets reduced to: r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE); i.e. when writing the string fails and the new flag WRITE_STRING_FILE_VERIFY_ON_FAILURE is specified we'll not return a failure immediately, but check the contents of the file. If it matches what we wanted to write we suppress the error and exit cleanly.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: split string parsing related calls from util.[ch] into parse-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
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-09-30fileio: make get_status_field() more genericAaro Koskinen
All users of get_status_field() expect the field pattern to occur in the beginning of a line, and the delimiter is ':'. Hardcode this into the function, and also skip any whitespace before ':' to support fields in files like /proc/cpuinfo. Add support for returning the full field value (currently stops on first whitespace). Rename the function so it's easier to ensure all callers switch to new semantics.
2015-07-06fileio: consolidate write_string_file*()Daniel Mack
Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
2015-07-06fileio: add 'enforce_newline' argument to write_string_stream()Daniel Mack
Add a flag to control whether write_string_stream() should always enforce a trailing newline character in the file.
2015-04-10shared: add process-util.[ch]Ronny Chevalier
2014-12-23env-util: don't include files from src/core/Lennart Poettering
2014-11-07copy: teach copy_bytes() sendfile() support, and then replace ↵Lennart Poettering
sendfile_full() by it
2014-11-05test: fileio - make coverity happyTom Gundersen
Explicitly check the length of the read. Fixes CID#1250803.
2014-10-31tests: add tests for fileio.cRonny Chevalier
add tests for the following functions: - write_string_file_no_create - load_env_file_pairs
2014-10-17environment: append unit_id to error messages regarding EnvironmentFileLukas Nykryn
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-09-30test-fileio: Remove dead checkThomas Hindoe Paaboel Andersen
t cannot be null here
2014-09-18tests: fix resource & mem leaksRonny Chevalier
2014-09-16test: silence a coverity reportThomas Hindoe Paaboel Andersen
We check the actual contents of the file on the line after but we might as well also check the number of bytes read here. Found by coverity. Fixes: CID#1237521
2014-08-18tests: add tests for fileio.cRonny Chevalier
add tests for: - write_string_stream - write_string_file - sendfile_full
2014-07-03machinectl: show /etc/os-release information of container in status outputLennart Poettering
2014-01-28always use the same code for creating temporary filesLennart Poettering
Let's unify our code here, and also always specifiy O_CLOEXEC.
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-12-12test-fileio: replace mktemp with mkstemp to avoid warningsThomas Hindoe Paaboel Andersen
This is a fairly useless thing to do but it makes the compilers and analyzers shut up about the use of mktemp.
2013-09-19Add more tests and fix capability loggingZbigniew Jędrzejewski-Szmek
2013-09-17test-fileio: assume that Buffers may be missingZbigniew Jędrzejewski-Szmek
2013-09-16Assume that /proc/meminfo can be missingZbigniew Jędrzejewski-Szmek
Travis tests are failing, probably because /proc/meminfo is not available in the test environment. The same might be true in some virtualized systems, so just treat missing /proc/meminfo as a sign that hibernation is not possible.
2013-09-13Advertise hibernation only if there's enough free swapZbigniew Jędrzejewski-Szmek
Condition that is checked is taken from upower: active(anon) < free swap * 0.98 This is really stupid, because the kernel knows the situation better, e.g. there could be two swap files, and then hibernation would be impossible despite passing this check, or the kernel could start supporting compressed swap and/or compressed hibernation images, and then this this check would be too stringent. Nevertheless, until we have something better, this should at least return a true negative if there's no swap. Logging of capabilities in the journal is changed to not strip leading zeros. I consider this more readable anyway. http://cgit.freedesktop.org/upower/tree/src/up-daemon.c#n613 https://bugzilla.redhat.com/show_bug.cgi?id=1007059
2013-09-11Allow tabs in environment filesZbigniew Jędrzejewski-Szmek
bash allows them, and so should we. string_has_cc is changed to allow tabs, and if they are not wanted, they must be now checked for explicitly. There are two other callers, apart from the env file loaders, and one already checked anyway, and the other is changed to check. https://bugs.freedesktop.org/show_bug.cgi?id=68592 https://bugs.gentoo.org/show_bug.cgi?id=481554
2013-07-30test-fileio: use random name for written fileZbigniew Jędrzejewski-Szmek
If two instances of test-fileio were run in parallel, they could fail when trying to write the same file. This predictable name in /tmp/ wasn't actually a security issue, because write_env_file would not follow symlinks, so this could be an issue only when running tests in parallel.
2013-07-26journalctl: use _COMM= match for scriptsZbigniew Jędrzejewski-Szmek
In case of scripts, _EXE is set to the interpreter name, and _COMM is set based on the file name. Add a match for _COMM, and _EXE if the interpreter is not a link (e.g. for yum, the interpreter is /usr/bin/python, but it is a link to /usr/bin/python2, which in turn is a link to /usr/bin/python2.7, at least on Fedora, so we end up with _EXE=/usr/bin/python2.7). I don't think that such link chasing makes sense, because the final _EXE name is more likely to change.
2013-04-18fileio.c: do not parse comments after non-whitespace charsHarald Hoyer
systemd does not want to understand comments after the first non-whitespace char occured. key=foo #comment will result into key == "foo #comment" key="foo" #comment will result into key == "foo#comment" "key= #comment" will result into key == "#comment" "key #comment" is an invalid line
2013-04-17core/execute: report invalid environment variables from filesHarald Hoyer
Because "export key=val" is not supported by systemd, an error is logged where the invalid assignment is coming from. Introduce strv_env_clean_log() to log invalid environment assignments, where logging is possible and allowed. parse_env_file_internal() is modified to allow WHITESPACE in keys, to report the issues later on.
2013-04-17fileio:parse_env_file_internal() fix environment file parsingHarald Hoyer
parse_env_file_internal() could not parse the following lines correctly: export key="val" key="val"#comment
2013-04-03fileio: write proper env var write-out codeLennart Poettering
This will properly escape all weird chars when writing env var files. With this in place we can now read and write environment files where the values contain arbitrary weird chars. This enables hostnamed and suchlike to finally properly save pretty host names with backlashes or quotes in them.
2013-04-03shared: rework env file readerLennart Poettering
Implement this with a proper state machine, so that newlines and escaped chars can appear in string assignments. This should bring the parser much closer to shell.