summaryrefslogtreecommitdiff
path: root/src/test/test-calendarspec.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: fix how we set $TZLennart Poettering2019-11-131-3/+6
| | | | | According to tzset(3) we need to prefix timezone names with ":". Let's do so hence, to avoid any ambiguities and follow documented behaviour.
* tree-wide: drop double newlineYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: introduce strerror_safe()Yu Watanabe2019-07-051-4/+5
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* test-calendarspec: add the test case from oss-fuzz 6886Zbigniew Jędrzejewski-Szmek2018-03-151-0/+1
| | | | Before the fix 55a30fd4e8 in this would crash in calendarspec_from_time_t().
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* Added timezone to the CalendarSpec, parser/formatter and the timedatectlIvan Kurnosov2017-09-171-0/+12
|
* calendarspec: parse unix timestamps (@...) (#5947)Zbigniew Jędrzejewski-Szmek2017-05-171-0/+5
| | | Fixes #5810.
* calendarspec: fix duplicate detection (#5310)Doug Christman2017-02-121-0/+1
| | | | a2eb5ea79c added a new field to `CalendarComponent`; update `normalize_chain` to compare all fields when dropping duplicates
* calendarspec: improve overflow handlingDouglas Christman2016-12-201-0/+2
| | | | | | Check if the parsed seconds value fits in an integer *after* multiplying by USEC_PER_SEC, otherwise a large value can trigger modulo by zero during normalization.
* calendarspec: allow repetition values with rangesDouglas Christman2016-12-161-5/+18
| | | | | "Every other hour from 9 until 5" can be written as `9..17/2:00` instead of `9,11,13,15,17:00`
* calendarspec: always interpret missing seconds as :00 (#4813)Doug Christman2016-12-061-0/+3
| | | | | | "*:*" should be equivalent to "*-*-* *:*:00" (minutely) rather than running every microsecond. Fixes #4804
* calendarspec: make specifications with ranges reversibleDouglas Christman2016-11-241-6/+7
| | | | "*-*-01..03" is now formatted as "*-*-01..03" instead of "*-*-01,02,03"
* calendarspec: allow whole second rangesDouglas Christman2016-11-241-0/+1
| | | | | Previously a string like "00:00:01..03" would fail to parse due to the ambiguity between a decimal point and the start of a range.
* calendarspec: make specifications with seconds wildcard reversibleDouglas Christman2016-11-241-0/+1
| | | | "*:*:*" is now formatted as "*:*:*" instead of "*:*:00/1"
* calendarspec: reject strings with spurious spaces and signsDouglas Christman2016-11-241-0/+3
| | | | | | strtoul() parses leading whitespace and an optional sign; check that the first character is a digit to prevent odd specifications like "00: 00: 00" and "-00:+00/-1".
* calendarspec: reject open weekday rangesDouglas Christman2016-11-241-0/+3
| | | | Forbid open ranges like "Tue.."; trailing commas are still OK.
* calendarspec: reject strings that only contain a timezoneDouglas Christman2016-11-241-0/+1
| | | | This makes " UTC" an illegal date specification.
* calendarspec: always interpret a missing time as 00:00:00Douglas Christman2016-11-241-0/+4
| | | | | "*-*-*" is now equivalent to "*-*-* 00:00:00" (daily) rather than "*-*-* *:*:*" (every second).
* calendarspec: add support for scheduling timers at the end of the monthDouglas Christman2016-11-231-0/+8
| | | | | | | | "*-*~1" => The last day of every month "*-02~3..5" => The third, fourth, and fifth last days in February "Mon 05~07/1" => The last Monday in May Resolves #3861
* calendarspec: add upper bound on yearDouglas Christman2016-11-231-0/+1
| | | | | Stop looking for matches after MAX_YEAR so impossible dates like "*-02-30" and "*-04-31" don't cause an infinite loop.
* tests: fix memleak in test-calendarspec (#4424)Evgeny Vereshchagin2016-10-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: ``` ==10750== ==10750== HEAP SUMMARY: ==10750== in use at exit: 96 bytes in 3 blocks ==10750== total heap usage: 1,711 allocs, 1,708 frees, 854,545 bytes allocated ==10750== ==10750== 96 (64 direct, 32 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3 ==10750== at 0x4C2DA60: calloc (vg_replace_malloc.c:711) ==10750== by 0x4EB3BDA: calendar_spec_from_string (calendarspec.c:771) ==10750== by 0x109675: test_hourly_bug_4031 (test-calendarspec.c:118) ==10750== by 0x10A00E: main (test-calendarspec.c:202) ==10750== ==10750== LEAK SUMMARY: ==10750== definitely lost: 64 bytes in 1 blocks ==10750== indirectly lost: 32 bytes in 2 blocks ==10750== possibly lost: 0 bytes in 0 blocks ==10750== still reachable: 0 bytes in 0 blocks ==10750== suppressed: 0 bytes in 0 blocks ==10750== ==10750== For counts of detected and suppressed errors, rerun with: -v ==10750== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ```
* test-calendarspec: test that hourly timers are incremented properlyZbigniew Jędrzejewski-Szmek2016-10-171-1/+24
| | | | Apparently this works just fine, so the issue in #4031 is elsewhere.
* util-lib: make timestamp generation and parsing reversible (#3869)Lennart Poettering2016-08-031-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves parsing and generation of timestamps and calendar specifications in two ways: - The week day is now always printed in the abbreviated English form, instead of the locale's setting. This makes sure we can always parse the week day again, even if the locale is changed. Given that we don't follow locale settings for printing timestamps in any other way either (for example, we always use 24h syntax in order to make uniform parsing possible), it only makes sense to also stick to a generic, non-localized form for the timestamp, too. - When parsing a timestamp, the local timezone (in its DST or non-DST name) may be specified, in addition to "UTC". Other timezones are still not supported however (not because we wouldn't want to, but mostly because libc offers no nice API for that). In itself this brings no new features, however it ensures that any locally formatted timestamp's timezone is also parsable again. These two changes ensure that the output of format_timestamp() may always be passed to parse_timestamp() and results in the original input. The related flavours for usec/UTC also work accordingly. Calendar specifications are extended in a similar way. The man page is updated accordingly, in particular this removes the claim that timestamps systemd prints wouldn't be parsable by systemd. They are now. The man page previously showed invalid timestamps as examples. This has been removed, as the man page shouldn't be a unit test, where such negative examples would be useful. The man page also no longer mentions the names of internal functions, such as format_timestamp_us() or UNIX error codes such as EINVAL.
* calendarspec: use ".." notation for ranges of weekdaysDouglas Christman2016-07-011-2/+5
| | | | | For backwards compatibility, both the new format (Mon..Wed) and the old format (Mon-Wed) are supported.
* calendarspec: allow ranges in date and time specificationsDouglas Christman2016-07-011-0/+5
| | | | Resolves #3042
* calendarspec: fix find_next skipping timesHristo Venev2016-02-221-0/+1
| | | | reset usec when bumping hours/minutes
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* test: calendarspec sub-second testsHristo Venev2015-11-171-1/+12
|
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-0/+1
| | | | | | | | | | | | | | 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.
* test: add calendarspec UTC testsHristo Venev2015-10-151-0/+47
|
* calendarspec: parse 'quarterly' and 'semi-annually' as shortcutsLennart Poettering2014-10-271-0/+4
|
* test: extend calendarspec test a bitLennart Poettering2012-11-231-2/+6
|
* timer: implement calendar time eventsLennart Poettering2012-11-231-0/+84