mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
69 lines
2.7 KiB
Plaintext
69 lines
2.7 KiB
Plaintext
#
|
|
# subunit C bindings.
|
|
# Copyright (C) 2006 Robert Collins <robertc@robertcollins.net>
|
|
#
|
|
# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
|
|
# license at the users choice. A copy of both licenses are available in the
|
|
# project source as Apache-2.0 and BSD. You may not use this file except in
|
|
# compliance with one of these two licences.
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# license you chose for the specific language governing permissions and
|
|
# limitations under that license.
|
|
|
|
This subtree contains an implementation of the subunit child protocol.
|
|
Currently I have no plans to write a test runner in C, so I have not written
|
|
an implementation of the parent protocol. [but will happily accept patches].
|
|
This implementation is built using SCons and tested via 'check'.
|
|
See the tests/ directory for the test programs.
|
|
You can use `make check` or `scons check` to run the tests.
|
|
|
|
The C protocol consists of four functions which you can use to output test
|
|
metadata trivially. See lib/subunit_child.[ch] for details.
|
|
|
|
However, this is not a test runner - subunit provides no support for [for
|
|
instance] managing assertions, cleaning up on errors etc. You can look at
|
|
'check' (http://check.sourceforge.net/) or
|
|
'gunit' (https://garage.maemo.org/projects/gunit) for C unit test
|
|
frameworks.
|
|
There is a patch for 'check' (check-subunit-*.patch) in this source tree.
|
|
Its also available as request ID #1470750 in the sourceforge request tracker
|
|
http://sourceforge.net/tracker/index.php. The 'check' developers have indicated
|
|
they will merge this during the current release cycle.
|
|
|
|
If you are a test environment maintainer - either homegrown, or 'check' or
|
|
'gunit' or some other, you will to know how the subunit calls should be used.
|
|
Here is what a manually written test using the bindings might look like:
|
|
|
|
|
|
void
|
|
a_test(void) {
|
|
int result;
|
|
subunit_test_start("test name");
|
|
# determine if test passes or fails
|
|
result = SOME_VALUE;
|
|
if (!result) {
|
|
subunit_test_pass("test name");
|
|
} else {
|
|
subunit_test_fail("test name",
|
|
"Something went wrong running something:\n"
|
|
"exited with result: '%s'", result);
|
|
}
|
|
}
|
|
|
|
Which when run with a subunit test runner will generate something like:
|
|
test name ... ok
|
|
|
|
on success, and:
|
|
|
|
test name ... FAIL
|
|
|
|
======================================================================
|
|
FAIL: test name
|
|
----------------------------------------------------------------------
|
|
RemoteError:
|
|
Something went wrong running something:
|
|
exited with result: '1'
|