summaryrefslogtreecommitdiff
path: root/src/test
AgeCommit message (Collapse)Author
2017-04-30more portable python shebangs (#5816)Jörg Thalheim
This is useful on systems like NixOS, where python3 is not in /usr/bin/python3 as well as for people using alternative ways to install python such as virtualenv/pyenv.
2017-04-29Merge pull request #5809 from keszybz/glob-safeMartin Pitt
Implement `safe_glob` that ignores "." and ".."
2017-04-29Merge pull request #5783 from keszybz/compiler-warning-fixesLennart Poettering
shared/extract-word: replace enum with int to avoid undefined behaviour
2017-04-27Merge branch 'master' into meson-no-libudevZbigniew Jędrzejewski-Szmek
2017-04-27tmpfiles: use safe_glob()Zbigniew Jędrzejewski-Szmek
This filters out "." and ".." from glob results. Fixes #5655 and #5644. Any judgements on whether the path is "safe" are removed. We will not remove "/" under any name (including "/../" and such), but we will remove stuff that is specified using paths that include "//", "/./" and "/../". Such paths can be created when joining strings automatically, or for other reasons, and people generally know what ".." and "." is. Tests are added to make sure that the helper functions behave as expected.
2017-04-27basic: add readdir_no_dot and safe_glob functionsZbigniew Jędrzejewski-Szmek
safe_glob filters out "." and "..". This converts all users of glob_extend() and glob_exists() to safe_glob.
2017-04-26meson: get rid of libfirewallMichael Biebl
2017-04-26meson: drop implicit libudev link dependenciesMichael Biebl
Executables which link against libshared do not need an explicit dependency on libudev, as libshared will make sure that those symbols are available.
2017-04-25test-sizeof: print the size of an enumZbigniew Jędrzejewski-Szmek
2017-04-25meson: also indent scripts with 8 spacesZbigniew Jędrzejewski-Szmek
2017-04-24meson: test-ns is manual, not just unsafeZbigniew Jędrzejewski-Szmek
2017-04-23meson: use "sh -eu" and make .sh +x, .py -xZbigniew Jędrzejewski-Szmek
Shell scripts should be executable so that meson reports their invocation succinctly (does not print 'sh' '-e'). Python scripts should not be executable so that meson does the detection of the right python binary itself. Add -u everywhere to catch potential errors.
2017-04-23meson: reindent all files with 8 spacesZbigniew Jędrzejewski-Szmek
The indentation for emacs'es meson-mode is added .dir-locals. All files are reindented automatically, using the lasest meson-mode from git. Indentation should now be fairly consistent.
2017-04-23meson: allow optional static linking of shared code in udev helpersZbigniew Jędrzejewski-Szmek
This makes the helper binaries significantly bigger (in some cases, the final size depends on link options and optimization level), and is only useful for distributions which want to provide the option to install udev without systemd. As the linking is improved, the difference between the columns might shrink, but it's unlikely that linking libshared statically could ever be more efficient. E.g. with -O0, no -flto: (static) (shared) src/udev/ata_id 999176 85696 src/udev/cdrom_id 1024344 111656 src/udev/collect 990344 81280 src/udev/scsi_id 1023592 115656 src/udev/v4l_id 811736 17744 When linked dynamically, install_rpath must be specified, so add that.
2017-04-23meson: add test-dlopenZbigniew Jędrzejewski-Szmek
test-dlopen is a very simple binary that is only linked with libc and libdl. From it we do dlopen() on the nss and pam modules to check that they are linked to all necessary libs. (meson-compiled nss modules are linked to less libraries, for whatever reason. I suspected that some deps are missing, but it turns out that my suspicions weren't justified, and the modules load just fine. Let's keep the test though, it is very quick, and might detect missing linkage in the future.)
2017-04-23test-nss: fix loading of modules under mesonZbigniew Jędrzejewski-Szmek
There is no .libs dirs under meson. Just try both paths.
2017-04-23meson: eliminate libsystemd_journal_internal and use libsystemd_internal lessZbigniew Jędrzejewski-Szmek
This simplifies things and leads to a smaller installation footprint. libsystemd_internal and libsystemd_journal_internal are linked into libystemd-shared and available to all programs linked to libsystemd-shared. libsystemd_journal_internal is not needed anymore, and libsystemd-shared is used everwhere. The few exceptions are: libsystemd.so, test-engine, test-bus-error, and various loadable modules.
2017-04-23meson: specify a timeout of 90 s for tests which take a bit longerZbigniew Jędrzejewski-Szmek
Both test-hashmap and test-benchmark need 10-11 s here, but might time out under load with the default meson timeout of 30 s.
2017-04-23meson: fix compilation with -Dnetworkd=false, -Dkmod=no, -Dlibgcrypt=noZbigniew Jędrzejewski-Szmek
The tests are included under the conditional too, instead of specifying 'ENABLE_NETWORKD' in the test definition array, because libnetworkd_core dependency is undefined if networkd is disabled.
2017-04-23meson: update linking for fixed meson linkingZbigniew Jędrzejewski-Szmek
With mesonbuid/meson#1545, meson does not propagate deps of a library when linking with that library. That's of course the right thing to do, but it exposes a bunch of missing deps. This compiles with both meson-0.39.1 and meson-git + pr/1545.
2017-04-23meson: add test-libudev-symZbigniew Jędrzejewski-Szmek
This is slightly complicated by the fact that files('libudev.h') cannot be used as an argument in custom_target command (string is required). This restriction should be lifted in future versions of mesons, so this could be simplified.
2017-04-23meson: add test-libsystemd-sym, fix linking of libsystemdZbigniew Jędrzejewski-Szmek
This is quite messy. I think libtool might have been using something like -Wl,--whole-archive, but I don't think meson has support for that. For now, just recompile all the sources for linking into libsystemd directly. This should not matter much for efficiency, since it's a few small files.
2017-04-23meson: create a static version of libshared and link libcore and some tests ↵Zbigniew Jędrzejewski-Szmek
to it This is what autoconf-based build does, and it makes test-bus-error and test-engine able to access the bus error mapping table. OTOH, this is a heavy price to pay: it would be excellent to link libcore.a to libsystemd-shared-NNN.so. Otherwise we duplicate the same code in 'systemd' and 'libsystemd-shared-NNN.so'. -rwxrwxr-x. 1 4075544 Apr 6 20:30 systemd* <-- libcore linked against libsystemd-shared.so -rwxrwxr-x. 1 5596504 Apr 9 14:07 systemd* <-- libcore linked against libsystemd-shared.a v2: - update for 6b5cf3ea621a5bfd218cd2249e066a52c0e73657
2017-04-23meson: define testsZbigniew Jędrzejewski-Szmek
Tests can be run with 'ninja-build test' or using 'mesontest'. '-Dtests=unsafe' can be used to include the "unsafe" tests in the test suite, same as with autotools. v2: - use more conf.get guards are optional components - declare deps on generated headers for test-{af,arphrd,cap}-list v3: - define environment for tests Most test don't need this, but to be consistent with autotools-based build, and to avoid questions which tests need it and which don't, set the same environment for all tests. v4: - rework test generation Use a list of lists to define each test. This way we can reduce the boilerplate somewhat, although the test listings are still pretty verbose. We can also move the definitions of the tests to the subdirs. Unfortunately some subdirs are included earlier than some of the libraries that test binaries are linked to. So just dump all definitions of all tests that cannot be defined earlier into src/test. The `executable` definitions are still at the top level, so the binaries are compiled into the build root. v5: - tag test-dnssec-complex as manual v6: - fix HAVE_LIBZ typo - add missing libgobject/libgio defs - mark test-qcow2 as manual
2017-04-21test-exec-util: drop duplicate constZbigniew Jędrzejewski-Szmek
gcc-7 warns about this with -Wduplicate-decl-specifier.
2017-04-04tree-wide: standardize on $(PACKAGE_VERSION) for the version stringZbigniew Jędrzejewski-Szmek
We defined both $(VERSION) and $(PACKAGE_VERSION) with the same contents. $(PACKAGE_VERSION) is slightly more descriptive, so settle on that, and drop the other define.
2017-03-29test-sizeof: add some struct-timespec related fieldsZbigniew Jędrzejewski-Szmek
Might help with #5264.
2017-03-29test-sizeof: do not link with libsystemd-sharedZbigniew Jędrzejewski-Szmek
This makes it much quicker to compile.
2017-03-03test: skip instead of fail if crypto kmods are not availableMartin Pitt
Package build machines may have module loading disabled, thus AF_ALG sockets are not available. Skip the tests that cover those (khash and id128) instead of failing them in this case. Fixes #5524
2017-02-28Merge pull request #5438 from ssahani/vxlan-addressLennart Poettering
networkd: add symlinks for Makefile (netdev and wait-online) , vxlan enhancements.
2017-02-24Fix missing space in comments (#5439)AsciiWolf
2017-02-24test: add support for in_addr_is_multicast testsSusant Sahani
2017-02-23Merge pull request #4670 from htejun/systemd-controller-on-unified-v2Lennart Poettering
Systemd controller on unified v2
2017-02-22test-cgroup-util: add a "test" to print out cg_is_*_wanted() valuesZbigniew Jędrzejewski-Szmek
This isn't terribly useful because /sys/fs/cgroup will usually be mounted. But it at least allows checking if the values make sense in this case.
2017-02-21test-env-util: fix typo leading to memleakZbigniew Jędrzejewski-Szmek
Partially fixes #5405.
2017-02-21Merge pull request #5131 from keszybz/environment-generatorsLennart Poettering
Environment generators
2017-02-20test-env-util: add more tests for "extended syntax"Zbigniew Jędrzejewski-Szmek
This is only the tip of the iceberg. It would be great to test all kinds of nesting, handling of invalid syntax, etc., but I'm leaving that for later.
2017-02-20basic: support default and alternate values for env expansionRay Strode
Sometimes it's useful to provide a default value during an environment expansion, if the environment variable isn't already set. For instance $XDG_DATA_DIRS is suppose to default to: /usr/local/share/:/usr/share/ if it's not yet set. That means callers wishing to augment XDG_DATA_DIRS need to manually add those two values. This commit changes replace_env to support the following shell compatible default value syntax: XDG_DATA_DIRS=/foo:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share} Likewise, it's useful to provide an alternate value during an environment expansion, if the environment variable isn't already set. For instance, $LD_LIBRARY_PATH will inadvertently search the current working directory if it starts or ends with a colon, so the following is usually wrong: LD_LIBRARY_PATH=/foo/lib:${LD_LIBRARY_PATH} To address that, this changes replace_env to support the following shell compatible alternate value syntax: LD_LIBRARY_PATH=/foo/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} [zj: gate the new syntax under REPLACE_ENV_ALLOW_EXTENDED switch, so existing callers are not modified.]
2017-02-20Tighten checking for variable validityZbigniew Jędrzejewski-Szmek
In the future we might want to allow additional syntax (for example "unset VAR". But let's check that the data we're getting does not contain anything unexpected.
2017-02-20Allow braceless variables to be expandedZbigniew Jędrzejewski-Szmek
(Only in environment.d files.) We have only basic compatibility with shell syntax, but specifying variables without using braces is probably more common, and I think a lot of people would be surprised if this didn't work.
2017-02-20basic: add new merge_env_file functionRay Strode
merge_env_file is a new function, that's like load_env_file, but takes a pre-existing environment as an input argument. New environment entries are merged. Variable expansion is performed. Falling back to the process environment is supported (when a flag is set). Alternatively this could be implemented as passing an additional fallback environment array, but later on we're adding another flag to allow braceless expansion, and the two flags can be combined in one arg, so there's less stuff to pass around.
2017-02-20basic: fix strv_env_get_n for unclean arraysRay Strode
If an environment array has duplicates, strv_env_get_n returns the results for the first match. This is wrong, because later entries in the environment are supposed to replace earlier entries.
2017-02-20exec-util: implement a set of callbacks to pass variables aroundZbigniew Jędrzejewski-Szmek
Only tests are added, otherwise the new code is unused.
2017-02-20env-util,fileio: immediately replace variables in load_env_file_push()Zbigniew Jędrzejewski-Szmek
strv_env_replace was calling env_match(), which in effect allowed multiple values for the same key to be inserted into the environment block. That's pointless, because APIs to access variables only return a single value (the latest entry), so it's better to keep the block clean, i.e. with just a single entry for each key. Add a new helper function that simply tests if the part before '=' is equal in two strings and use that in strv_env_replace. In load_env_file_push, use strv_env_replace to immediately replace the previous assignment with a matching name. Afaict, none of the callers are materially affected by this change, but it seems like some pointless work was being done, if the same value was set multiple times. We'd go through parsing and assigning the value for each entry. With this change, we handle just the last one.
2017-02-20basic/exec-util: add support for synchronous (ordered) executionZbigniew Jędrzejewski-Szmek
The output of processes can be gathered, and passed back to the callee. (This commit just implements the basic functionality and tests.) After the preparation in previous commits, the change in functionality is relatively simple. For coding convenience, alarm is prepared *before* any children are executed, and not before. This shouldn't matter usually, since just forking of the children should be pretty quick. One could also argue that this is more correct, because we will also catch the case when (for whatever reason), forking itself is slow. Three callback functions and three levels of serialization are used: - from individual generator processes to the generator forker - from the forker back to the main process - deserialization in the main process v2: - replace an structure with an indexed array of callbacks
2017-02-20core/manager: split out creation of serialization fd out to a helperZbigniew Jędrzejewski-Szmek
There is a slight change in behaviour: the user manager for root will create a temporary file in /run/systemd, not /tmp. I don't think this matters, but simplifies implementation.
2017-02-19test: re-drop assumption that /run is a mount point, part 2 (#5386)Martin Pitt
Commit cc3901613 only fixed one place, fix the other one too.
2017-02-17test: re-drop assumption that /run is a mount point (#5377)Martin Pitt
Commit 436e916ea introduced the assumption into test-stat-util that /run is a tmpfs mount point. This is not the case in build chroots such as Fedora's mock or Debian's sbuild. So only assert that /run is a tmpfs and not a btrfs if /run is actually a mount point. This will then still be asserted with installed tests.
2017-02-17machined: when copying files from/to userns containers chown to rootLennart Poettering
This changes the file copy logic of machined to set the UID/GID of all copied files to 0 if the host and container do not share the same user namespace. Fixes: #4078
2017-02-17copy: change the various copy_xyz() calls to take a unified flags parameterLennart Poettering
This adds a unified "copy_flags" parameter to all copy_xyz() function calls, replacing the various boolean flags so far used. This should make many invocations more readable as it is clear what behaviour is precisely requested. This also prepares ground for adding support for more modes later on.