GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SHTK_UNITTEST_ASSERT_FILE(3) FreeBSD Library Functions Manual SHTK_UNITTEST_ASSERT_FILE(3)

shtk_unittest_assert_file
Validates the contents of a file against golden data

shtk_import unittest

shtk_unittest_assert_file golden_spec actual_file

The shtk_unittest_assert_file function verifies that actual_file, which must exist, matches some predefined contents specified by golden_spec.

The valid values for golden_spec are of the form:

empty
actual_file must be empty.
not-empty
actual_file must not be empty.
ignore
The contents of actual_file are irrelevant.
file:<path>
The contents of actual_file must match the contents of the file path.
inline:<text>
The contents of actual_file must match the inline contents provided in text. Note that text can include escape sequences.
match:<regexp>
The contents of actual_file must match the given regular expression in regexp.
not-match:<regexp>
The contents of actual_file must not match the given regular expression in regexp.
save:<path>
actual_file is saved to path for further inspection by the test case. This is not useful in the context of shtk_unittest_assert_file but comes in handy when used in conjunction of shtk_unittest_assert_command(3).
stdin
The contents of actual_file must match the golden contents provided via the standard input.

The following examples all pass:
touch my_file
assert_file empty my_file

echo "foo" >my_file
assert_file inline:"foo\n" my_file

echo "bar" >>my_file
cp my_file golden
assert_file file:golden my_file
assert_file stdin my_file <golden

assert_file match:"fo" my_file
assert_file not-match:"abcde" my_file

shtk(3), shtk_unittest(3)

shtk_unittest_assert_file first appeared in shtk 1.6.
November 9, 2014 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.