<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openssl.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ckomlo</id>
	<title>OpenSSLWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openssl.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ckomlo"/>
	<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php/Special:Contributions/Ckomlo"/>
	<updated>2026-04-11T17:17:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=How_To_Write_Unit_Tests_For_OpenSSL&amp;diff=1859</id>
		<title>How To Write Unit Tests For OpenSSL</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=How_To_Write_Unit_Tests_For_OpenSSL&amp;diff=1859"/>
		<updated>2014-08-05T21:39:42Z</updated>

		<summary type="html">&lt;p&gt;Ckomlo: /* Forking the Repo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an outline of the basic process and principles to follow when writing unit tests. This document will evolve quite a bit as the community gains experience.&lt;br /&gt;
&lt;br /&gt;
==Mechanics ==&lt;br /&gt;
=== Forking the Repo ===&lt;br /&gt;
&lt;br /&gt;
For now, people contributing new unit tests for uncovered code (as opposed to submitting tests with new code changes) should fork [https://github.com/mbland/openssl Mike Bland's GitHub repository] and issue changes via [https://help.github.com/articles/using-pull-requests GitHub pull requests] to this repo. &lt;br /&gt;
&lt;br /&gt;
Remember to do all development on a topic branch (not &amp;lt;code&amp;gt;master&amp;lt;/code&amp;gt;). Tests committed to this repo will occasionally get merged into the master OpenSSL repo.&lt;br /&gt;
&lt;br /&gt;
Be sure to set up the [https://github.com/openssl/openssl OpenSSL master repository] as your upstream remote as per [https://help.github.com/articles/fork-a-repo#step-3-configure-remotes GitHub's instructions on configuring remotes], and pull in upstream changes frequently. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd my-openssl-repo&lt;br /&gt;
$ git remote add upstream https://github.com/openssl/openssl.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the following output from &amp;lt;code&amp;gt;git remove -v&amp;lt;/code&amp;gt; (where &amp;lt;code&amp;gt;$USER&amp;lt;/code&amp;gt; is your GitHub username):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git remote -v&lt;br /&gt;
origin  https://github.com/$USER/openssl.git (fetch)&lt;br /&gt;
origin  https://github.com/$USER/openssl.git (push)&lt;br /&gt;
upstream        https://github.com/openssl/openssl.git (fetch)&lt;br /&gt;
upstream        https://github.com/openssl/openssl.git (push)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rationale per Matt Caswell: We should think about process here. If you are going off to recruit an army of people writing tests then I wonder if it is worth setting up a separate github repository whilst you are building up the tests. We can then merge in from that on a periodic basis. I wouldn't want availability of openssl team committers to be a bottle neck.&lt;br /&gt;
&lt;br /&gt;
=== Check out the Tools and Tips page ===&lt;br /&gt;
[[Testing and Development Tools and Tips]] has information on tools that may make navigating and building the code a bit easier.&lt;br /&gt;
&lt;br /&gt;
=== Use the Test Template Generator ===&lt;br /&gt;
TODO(mbland): Get template generator checked-in. Maybe have a template generator for each library, e.g. &amp;lt;code&amp;gt;ssl/new-test.sh&amp;lt;/code&amp;gt; that has additional setup boilerplate specific to the &amp;lt;code&amp;gt;ssl&amp;lt;/code&amp;gt; library.&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;test/new-test.sh&amp;lt;/code&amp;gt; script to generate a skeleton test file. ([https://github.com/mbland/openssl/compare/test-util pending in the test-util branch])&lt;br /&gt;
&lt;br /&gt;
=== Add Makefile Targets ===&lt;br /&gt;
The following instructions use the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; targets for &amp;lt;code&amp;gt;ssl/heartbeat_test.c&amp;lt;/code&amp;gt; as an example.&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; for the library containing the test, add the test source file to the &amp;lt;code&amp;gt;TEST&amp;lt;/code&amp;gt; variable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ssl/Makefile&lt;br /&gt;
TEST=ssltest.c heartbeat_test.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;test/Makefile&amp;lt;/code&amp;gt;:&lt;br /&gt;
* add a variable for the test target near the top of the file, right after the existing test variables&lt;br /&gt;
* use the variable to add an executable target to the &amp;lt;code&amp;gt;EXE&amp;lt;/code&amp;gt; variable&lt;br /&gt;
* use the variable to add an object file target to the &amp;lt;code&amp;gt;OBJ&amp;lt;/code&amp;gt; variable&lt;br /&gt;
* use the variable to add a source file target to the &amp;lt;code&amp;gt;SRC&amp;lt;/code&amp;gt; variable&lt;br /&gt;
* add the test target to the &amp;lt;code&amp;gt;alltests&amp;lt;/code&amp;gt; target&lt;br /&gt;
* add the target to execute the test&lt;br /&gt;
* add the target to build the test executable&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# test/Makefile&lt;br /&gt;
HEARTBEATTEST=  heartbeat_test&lt;br /&gt;
EXE=  ... $(HEARTBEATTEST)$(EXE_EXT)&lt;br /&gt;
OBJ= ... $(HEARTBEATTEST).o&lt;br /&gt;
SRC= ... $(HEARTBEATTEST).c&lt;br /&gt;
alltests: \&lt;br /&gt;
        ... test_heartbeat&lt;br /&gt;
&lt;br /&gt;
test_heartbeat: $(HEARTBEATTEST)$(EXE_EXT)&lt;br /&gt;
  ../util/shlib_wrap.sh ./$(HEARTBEATTEST)&lt;br /&gt;
&lt;br /&gt;
$(HEARTBEATTEST)$(EXE_EXT): $(HEARTBEATTEST).o $(DLIBCRYPTO) testutil.o&lt;br /&gt;
  @target=$(HEARTBEATTEST) testutil=testutil.o; $(BUILD_CMD)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Run &amp;lt;code&amp;gt;make links &amp;amp;&amp;amp; make depend&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Finally, run &amp;lt;code&amp;gt;make links &amp;amp;&amp;amp; make depend&amp;lt;/code&amp;gt; to link the new test into the &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt; directory and automatically generate the header file dependencies.&lt;br /&gt;
&lt;br /&gt;
=== Building and Running the Test ===&lt;br /&gt;
If you're initially developing on Mac OS X or (for now) FreeBSD 10, just use the stock method of building and testing:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./config enable-unit-test &amp;amp;&amp;amp; make &amp;amp;&amp;amp; make test&lt;br /&gt;
&lt;br /&gt;
# To execute just one specific test&lt;br /&gt;
$ make TESTS=test_heartbeat test &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ultimately the test will have to compile and pass with developer flags enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./GitConfigure debug-ben-debug-64-clang enable-unit-test&lt;br /&gt;
$ ./GitMake -j 2&lt;br /&gt;
$ ./GitMake test_heartbeat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above currently doesn't work on Mac OS X or FreeBSD &amp;gt; 9.1. The [https://github.com/mbland/openssl/commit/a3984ff8a2e84132f221557bc26415314daf3259 {,darwin64-}debug-test-64-clang Configure targets] commit, which should go in soon as part of [https://github.com/openssl/openssl/pull/145 pull request #145], should solve the issues. Other commits from #145 contain other OS X-specific fixes.&lt;br /&gt;
&lt;br /&gt;
=== Keep your repo up-to-date ===&lt;br /&gt;
Periodically run the following to keep your branch up-to-date:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git fetch upstream master&lt;br /&gt;
$ git rebase upstream/master&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will pull all the updates from the master OpenSSL repository into your repository, then update your branch to apply your changes on top of the latest updates.&lt;br /&gt;
&lt;br /&gt;
=== Send a pull request ===&lt;br /&gt;
When your test is ready, send a [https://help.github.com/articles/using-pull-requests GitHub pull request]. Note that the pull request should be based on the &amp;lt;code&amp;gt;tests&amp;lt;/code&amp;gt; branch of Mike's repository, not &amp;lt;code&amp;gt;master&amp;lt;/code&amp;gt;. (This should be the default; let Mike know if it doesn't appear to be!) We'll review the code, and when it's ready, it'll get merged into Mike's repository. From there, it will eventually get pulled into the master OpenSSL repository.&lt;br /&gt;
&lt;br /&gt;
== Style ==&lt;br /&gt;
[http://mike-bland.com/2014/06/05/pseudo-xunit-pattern.html The Pseudo-xUnit Pattern] is that established by [http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=ssl/heartbeat_test.c ssl/heartbeat_test.c]. This pattern organizes code in a fashion reminiscent of the [http://en.wikipedia.org/wiki/XUnit xUnit] family of unit testing frameworks, without actually using a testing framework. This should lower the barrier to entry for people wanting to write unit tests, but enable a relatively easy migration to an xUnit-based framework if we decide to do so one day.&lt;br /&gt;
&lt;br /&gt;
Some of the basic principles to follow are:&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; the header for the code under test first ===&lt;br /&gt;
Having the header file for the code under test appear as the first &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive ensures that that file is self-contained, i.e. it includes every header file it depends on, rather than relying on client code to include its dependencies.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;#include &amp;quot;testutil.h&amp;quot;&amp;lt;/code&amp;gt; should come second ===&lt;br /&gt;
&amp;lt;code&amp;gt;test/testutil.h&amp;lt;/code&amp;gt; contains the helper macros used in writing OpenSSL tests. Since the tests will be linked into &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt; by the [[#Run_make_links_.26.26_make_depend|make links]] step, and built in the &amp;lt;code&amp;gt;test/&amp;lt;/code&amp;gt; directory, the &amp;quot;testutil.h&amp;quot; file will appear to be in the same directory as the test file.&lt;br /&gt;
&lt;br /&gt;
=== Define a fixture structure ===&lt;br /&gt;
The fixture structure should contain all of the inputs to the code under test and all of the expected result values. It should also contain a &amp;lt;code&amp;gt;const char*&amp;lt;/code&amp;gt; for the name of the test case function that created it, to aid in error message formatting. Even though the fixture may contain dynamically-allocated members, the fixture itself should be copied by value to reduce the necessary degree of memory management in a small unit test program.&lt;br /&gt;
&lt;br /&gt;
=== Define set_up() and tear_down() functions for the fixture ===&lt;br /&gt;
&amp;lt;code&amp;gt;set_up()&amp;lt;/code&amp;gt; should return a newly-initialized test fixture structure. It should take the name of the test case as an argument (i.e. &amp;lt;code&amp;gt;__func__&amp;lt;/code&amp;gt;) and assign it to the fixture. All of the fixture members should be initialized, which each test case function can then override as needed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tear_down()&amp;lt;/code&amp;gt; should take the fixture as an argument and release any resources allocated by &amp;lt;code&amp;gt;set_up()&amp;lt;/code&amp;gt;. It can also call any library-wide error printing routines (e.g. &amp;lt;code&amp;gt;ERR_print_errors_fp(stderr)&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=== Use &amp;lt;code&amp;gt;SETUP_TEST_FIXTURE()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EXECUTE_TEST()&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;test/testutil.h&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Each test case function should call &amp;lt;code&amp;gt;set_up()&amp;lt;/code&amp;gt; as its first statement, and should call &amp;lt;code&amp;gt;tear_down()&amp;lt;/code&amp;gt; just before returning. This is handled in a uniform fashion when using the &amp;lt;code&amp;gt;SETUP_TEST_FIXTURE()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EXECUTE_TEST()&amp;lt;/code&amp;gt; helper macros from [http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=test/testutil.h test/testutil.h]. See the comments in &amp;lt;code&amp;gt;test/testutil.h&amp;lt;/code&amp;gt; for usage, and &amp;lt;code&amp;gt;ssl/heartbeat_test.c&amp;lt;/code&amp;gt; for an example of how to wrap the macros for a specific unit test.&lt;br /&gt;
&lt;br /&gt;
=== Use test case functions, not a table of fixtures ===&lt;br /&gt;
Individual test case functions that call a common execution function are much more readable and maintainable than a loop over a table of fixture structures. Explicit fixture variable assignments aid comprehension when reading a specific test case, which saves time and energy when trying to understand a test or diagnose a failure. When a new member is added to an existing fixture, &amp;lt;code&amp;gt;set_up()&amp;lt;/code&amp;gt; can set a default for all test cases, and only the test cases that rely on that new member need to be updated.&lt;br /&gt;
&lt;br /&gt;
=== Use very descriptive test case names ===&lt;br /&gt;
Give tests long, descriptive names that provide ample context for the details of the test case. Good test names are also help produce good error messages.&lt;br /&gt;
&lt;br /&gt;
=== Group test cases into &amp;quot;suites&amp;quot; by naming convention ===&lt;br /&gt;
Give logically-related tests the same prefix, e.g. &amp;lt;code&amp;gt;test_dtls1_&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;test_tls1&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;ssl/heartbeat_test.c&amp;lt;/code&amp;gt;. If need be, you can define suite-specific &amp;lt;code&amp;gt;set_up()&amp;lt;/code&amp;gt; functions that call the common &amp;lt;code&amp;gt;set_up()&amp;lt;/code&amp;gt; and elaborate on it. (This generally shouldn't be necessary for &amp;lt;code&amp;gt;tear_down()&amp;lt;/code&amp;gt;.)&lt;br /&gt;
&lt;br /&gt;
=== Keep individual test case functions focused on one thing ===&lt;br /&gt;
If the test name contains the word &amp;quot;and&amp;quot;, consider breaking it into two or more separate test case functions.&lt;br /&gt;
&lt;br /&gt;
=== Write very descriptive error messages ===&lt;br /&gt;
Include the test case function name in each error message, and explain in detail the context for the assertion that failed. Include the expected result (contained in the fixture structure) and the actual result returned from the code under test. Write helper methods for complex values as needed (e.g. &amp;lt;code&amp;gt;print_payload()&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;ssl/heartbeat_test.c&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
=== Return zero on success and one on failure ===&lt;br /&gt;
The return value will be used to tally the number of test cases that failed. Even if multiple assertions fail for a single test case, the result should be exactly one.&lt;br /&gt;
&lt;br /&gt;
=== Register each test case using ADD_TEST() and execute using run_tests() ===&lt;br /&gt;
Whatever function is used as the test runner, be that &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt; or a separate function called by &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt;, add your test case functions to that function using &amp;lt;code&amp;gt;ADD_TEST()&amp;lt;/code&amp;gt; and execute them using &amp;lt;code&amp;gt;run_tests()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;run_tests()&amp;lt;/code&amp;gt; will add up the total number of failed test cases and report that number as the last error message of the test. The return value of &amp;lt;code&amp;gt;run_tests()&amp;lt;/code&amp;gt; should be the value returned from &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt;, which will be &amp;lt;code&amp;gt;EXIT_FAILURE&amp;lt;/code&amp;gt; if any test cases failed, &amp;lt;code&amp;gt;EXIT_SUCCESS&amp;lt;/code&amp;gt; otherwise.&lt;br /&gt;
&lt;br /&gt;
TODO(mbland): create some kind of automated script or editor macros?&lt;br /&gt;
&lt;br /&gt;
=== Disable for Windows (for now) ===&lt;br /&gt;
Until we solve the private-symbol problem on Windows, we will need to wrap our unit test code in the following &amp;lt;code&amp;gt;#ifdef&amp;lt;/code&amp;gt; block:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#if !defined(OPENSSL_SYS_WINDOWS)&lt;br /&gt;
&lt;br /&gt;
/* All the test code, including main() */&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])                                                &lt;br /&gt;
    {&lt;br /&gt;
        return EXIT_SUCCESS;                                                    &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
#endif /* OPENSSL_NO_WINDOWS  */&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Samples ==&lt;br /&gt;
Existing tests that can be used as models for new tests.&lt;br /&gt;
* [http://git.openssl.org/gitweb/?p=openssl.git;a=blob;f=ssl/heartbeat_test.c ssl/heartbeat_test.c]: Follows [http://mike-bland.com/2014/06/05/pseudo-xunit-pattern.html the Pseudo-xUnit pattern]&lt;/div&gt;</summary>
		<author><name>Ckomlo</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Unit_Testing&amp;diff=1766</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Unit_Testing&amp;diff=1766"/>
		<updated>2014-06-20T16:57:31Z</updated>

		<summary type="html">&lt;p&gt;Ckomlo: /* Tutor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page will track the effort to improve unit test and other automated test coverage for OpenSSL. Everyone is encouraged to help with this effort, but this page will track which community members have accepted specific responsibilities, and what tasks are currently underway.&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
&lt;br /&gt;
The goals of this project are:&lt;br /&gt;
&lt;br /&gt;
* Establish a written contribution/code review policy that requires:&lt;br /&gt;
** tests for every new code change, except for very trivial changes that do not directly impact program logic (e.g. documentation fixes, string constant updates, build script tweaks); this can be limited to an agreed-upon subset of the code to start, but would hopefully be expanded to cover most, if not all, of the code base&lt;br /&gt;
** tests for every bugfix &lt;br /&gt;
** smaller, well-tested changes building up to a complete feature (as opposed to large and/or untested changes that implement a large, complex feature all at once) &lt;br /&gt;
* Establish a schedule of Build Cops and Tutors to begin enforcing rollbacks/fixes and to help shepherd new contributors through the testing process.&lt;br /&gt;
* Set up a series of publicly-accessible continuous integration servers using whatever system the community prefers (e.g. Jenkins, Buildbot, etc.). These can be dedicated hardware or possibly Amazon Web Services-based. Establish a written policy that these remain green at all times, and that breakages be rolled-back or fixed within no more than 30 minutes.&lt;br /&gt;
&lt;br /&gt;
We can add more concrete goals to this list after we make progress on these. Getting people to own roles, setting up build infrastructure, and setting and enforcing policy are important first steps. Upon that foundation, we can begin to make serious progress towards improved test coverage, code quality, and defect prevention.&lt;br /&gt;
&lt;br /&gt;
== Discussion List ==&lt;br /&gt;
[https://groups.google.com/d/forum/openssl-testing openssl-testing] is the mailing list dedicated to the unit/automated testing effort, to avoid clogging openssl-dev. Membership is open to whoever wishes to join, even if only to lurk. Ideally all testing discussions will eventually move to openssl-dev once we have processes, tools, conventions, etc. in place.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
We can define new roles as needed. The success of this effort will be inversely proportional to the number of roles with any one individual's name next to them. Each role can have more than one person filling it, but needs specific people to fill them. &lt;br /&gt;
&lt;br /&gt;
The point is not to tell people what to do and not do: it’s to establish clear responsibilities so everyone can run with them right away and begin applying their creative energy to solutions, rather than waste it figuring out what the hell is going on, what they should do to contribute, and who they need to coordinate with to get things done.&lt;br /&gt;
&lt;br /&gt;
=== Organizer===&lt;br /&gt;
&lt;br /&gt;
Contact: [mailto:mbland@acm.org Mike Bland]&lt;br /&gt;
&lt;br /&gt;
Ensures the overall effort is making progress by facilitating communication, removing obstacles, and making hands-on contributions when necessary.&lt;br /&gt;
&lt;br /&gt;
=== Tech Writer ===&lt;br /&gt;
&lt;br /&gt;
Contacts: [mailto:mbland@acm.org Mike Bland], Sandeep Mankar, Chelsea Komlo, Graham Brooks&lt;br /&gt;
&lt;br /&gt;
Maintains documentation of tools, techniques, outstanding issues, etc. May maintain a code review/testing style guide based on the community consensus. Also documents who currently fills each role, as well as who might've filled it in the past.&lt;br /&gt;
&lt;br /&gt;
=== Buildmaster ===&lt;br /&gt;
&lt;br /&gt;
Contacts:  [mailto:mbland@acm.org Mike Bland], Isaac Truett, Dileep Bapat, Graham Brooks&lt;br /&gt;
&lt;br /&gt;
Sets up and maintains automated builds and any infrastructure used to monitor them and report breakage.&lt;br /&gt;
&lt;br /&gt;
=== Toolsmith ===&lt;br /&gt;
&lt;br /&gt;
Contact: Tony Aiuto&lt;br /&gt;
&lt;br /&gt;
Maintains any tools and frameworks that are a part of the core build process; proposes, integrates, and/or retires existing tools.&lt;br /&gt;
&lt;br /&gt;
=== Tutor ===&lt;br /&gt;
&lt;br /&gt;
Contacts: [mailto:mbland@acm.org Mike Bland], Darshan Mody, Tom Francis, Brian N. Makin, Edward Knapp, Dileep Bapat, Graham Brooks&lt;br /&gt;
&lt;br /&gt;
Helps contributors, particularly new contributors, with the details of writing unit or other automated tests. May be assigned by the reviewer of a patch to help a contributor get a new change under test. Submission of the patch should require the approval of the tutor in most cases. (Should ideally be more than one person.)&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
The current list is posted in the [http://goo.gl/5u9nbw OpenSSL Testing Tasks Google Spreadsheet].&lt;br /&gt;
&lt;br /&gt;
(Would be nice to enable the [http://www.mediawiki.org/wiki/Extension:Widget MediaWiki Widget extension] and the [http://www.mediawikiwidgets.org/Google_Spreadsheet Google Spreadsheet widget].)&lt;br /&gt;
&lt;br /&gt;
== Howtos and Style Guides ==&lt;br /&gt;
Documents that provide background on specific testing issues and idioms should be linked from here.&lt;br /&gt;
&lt;br /&gt;
* [[How To Write Unit Tests For OpenSSL]]&lt;br /&gt;
* [http://mike-bland.com/2014/06/05/pseudo-xunit-pattern.html The Pseudo-xUnit Pattern]&lt;br /&gt;
* [[Testing and Development Tools and Tips]]&lt;br /&gt;
&lt;br /&gt;
== Discussion Topics ==&lt;br /&gt;
These are discussions related to some of the current testing tasks.&lt;br /&gt;
&lt;br /&gt;
=== First Area of Focus ===&lt;br /&gt;
Matt Caswell: One criterion might be ease of testing. If you were going down that route you might choose some of the low level packages within libcrypto which are relatively self-contained. I'm not talking about the crypto algorithms themselves (there are at least *some* tests for those), I'm thinking more about bio, pem, x509, x509v3, etc.&lt;br /&gt;
&lt;br /&gt;
Another criterion might be where you get the most value. I suspect we will get the most value from a really good set of unit tests for libssl. I suspect this might be a big ask to start off with (you would probably have to mock out a lot of stuff).&lt;br /&gt;
&lt;br /&gt;
=== Build Systems/Machines ===&lt;br /&gt;
Where can we get the machines? Is someone willing to donate them? What system should we use?&lt;br /&gt;
&lt;br /&gt;
=== Get Unit Tests to Build on Windows ===&lt;br /&gt;
Steve Henson on building ssl/heartbeat_test.c on Windows: The first problem is that __func__ isn't understood. Changing that to __FUNCTION__ resolves that easily enough.&lt;br /&gt;
&lt;br /&gt;
The second problem is more serious. Windows (and a couple of other platforms IIRC) is strict about only exporting approved symbols from global headers in shared libraries and wont export internal only functions.&lt;br /&gt;
&lt;br /&gt;
That means you get linker errors:&lt;br /&gt;
&lt;br /&gt;
heartbeat_test.obj : error LNK2019: unresolved external symbol _ssl3_setup_buffe&lt;br /&gt;
rs referenced in function _set_up&lt;br /&gt;
heartbeat_test.obj : error LNK2019: unresolved external symbol _ssl_init_wbio_bu&lt;br /&gt;
ffer referenced in function _set_up&lt;br /&gt;
heartbeat_test.obj : error LNK2019: unresolved external symbol _tls1_process_hea&lt;br /&gt;
rtbeat referenced in function _set_up_tls&lt;br /&gt;
heartbeat_test.obj : error LNK2019: unresolved external symbol _dtls1_process_he&lt;br /&gt;
artbeat referenced in function _set_up_dtls&lt;br /&gt;
out32dll\heartbeat_test.exe : fatal error LNK1120: 4 unresolved externals&lt;br /&gt;
NMAKE : fatal error U1077: '&amp;quot;C:\Program Files (x86)\Microsoft Visual Studio 11.0&lt;br /&gt;
\VC\BIN\link.EXE&amp;quot;' : return code '0x460'&lt;br /&gt;
&lt;br /&gt;
Potential solutions:&lt;br /&gt;
* http://stackoverflow.com/questions/7759777/is-it-possible-to-test-internal-class-from-a-c-dll-using-mstest&lt;br /&gt;
* http://stackoverflow.com/questions/19934714/googletest-c-unit-testing-linking-error&lt;br /&gt;
* http://stackoverflow.com/questions/14010627/unresolved-externals-when-compiling-unit-tests-for-visual-c-2012&lt;br /&gt;
&lt;br /&gt;
ifdef'd out (for now): https://github.com/openssl/openssl/commit/7ce79a5bfdbcd53ae75f85e94eed665a05b5dea3&lt;br /&gt;
&lt;br /&gt;
=== How to Manage Private Symbols ===&lt;br /&gt;
Steve Henson: As this also affects other platforms a general solution might be in order.&lt;br /&gt;
&lt;br /&gt;
One option is to link to static libraries as has been mentioned. If you have a&lt;br /&gt;
lot of unit tests you could end up with a lot of large binaries. Would need some&lt;br /&gt;
changes to the dreaded Windows build system too.&lt;br /&gt;
&lt;br /&gt;
A different option would be to export the unit test functions through a&lt;br /&gt;
structure pointer which a function returns. So you'd have something like..&lt;br /&gt;
&lt;br /&gt;
unit_test = SSL_get_unit_test_funcs();&lt;br /&gt;
&lt;br /&gt;
unit_test.some_internal_funcction(...);&lt;br /&gt;
&lt;br /&gt;
Where the actual structure is opaque to applications (so they aren't tempted to&lt;br /&gt;
poke around in internals) but visible to the unit test code. Then the unit test&lt;br /&gt;
code doesn't call any internal functions not defined in there and doesn't need&lt;br /&gt;
to load private headers (unless it needs them for some definitions).&lt;br /&gt;
&lt;br /&gt;
Mike Bland: This is an interesting idea, though I'd expect the unit tests will&lt;br /&gt;
still need access to internal headers.&lt;br /&gt;
&lt;br /&gt;
But I have a question: Why do any of the symbols need to be private?&lt;br /&gt;
Is that degree of encapsulation necessary, and does it really&lt;br /&gt;
discourage irresponsible clients? The source code is open, so people&lt;br /&gt;
can always build their own copy and depend on internals if they really&lt;br /&gt;
want to, and the default UNIX/Linux/OS X build (i.e. ./configure &amp;amp;&amp;amp;&lt;br /&gt;
make &amp;amp;&amp;amp; make test) doesn't lock down internal symbols. Have&lt;br /&gt;
dependencies on internal APIs ever been a problem in practice?&lt;br /&gt;
&lt;br /&gt;
I'm not saying I feel strongly either way, but it seems that clients&lt;br /&gt;
should be clear that the public API is what's available in&lt;br /&gt;
openssl/include, and shouldn't depend on anything else. I just don't&lt;br /&gt;
understand what making symbols private buys anyone in the context of&lt;br /&gt;
OpenSSL, in light of how it appears to complicate the ability to unit&lt;br /&gt;
test.&lt;br /&gt;
&lt;br /&gt;
Not trying to be argumentative, I just want to understand the&lt;br /&gt;
rationale. I'll work with whatever environment I have to.&lt;br /&gt;
&lt;br /&gt;
Tom Francis: Making the symbols private allows the link editors on Windows and pretty much every UNIX system that doesn't use GNU ld to:&lt;br /&gt;
1) Run much, much faster at link time (not a minor consideration for most of the software I've worked on); and&lt;br /&gt;
2) optimize the final binary to load much faster.&lt;br /&gt;
Last time I checked, there was a minor improvement for GNU ld for #1, but it's trivial compared to Windows and HP's link editor, e.g. (I can't overstate the difference there).  The runtime improvement is also dramatic on Windows, HP-UX, and AIX (we're talking tens for milliseconds for libraries that are much smaller than OpenSSL -- never tried it with OpenSSL, too lazy to mark everything, after having just done so for the library I was really interested in).&lt;br /&gt;
&lt;br /&gt;
If you want to avoid a bunch of small binaries, you could combine all the unit tests into a single test application, and use multiple runs of it for each test, similar to how the openssl binary is created; if you link the object files directly (or a static library), you avoid the private symbols issue.  Of course, this may be an issue for some of the embedded systems, where the loading a large binary for running the tests might not be acceptable (but might be preferable to a bunch of binaries?).  Mike Bland was concerned about parallelization, and for any kind of automated tests on commits, that's a big point, if you can guarantee that each system only compiles/executes a limited number of tests (it could be useful for OS vendors, too).  For the average OpenSSL user, that's not really a consideration; an average user is more likely concerned with how long (wall clock) it takes to compile and run the tests, and depending on the size of a single binary v the size of each smaller binary, it'll vary from system to system (generally, it'll be many times faster to create a single large binary than a few hundred smaller binaries, but the larger the binary, the longer it takes to load -- at some point, the load time might well outweigh the hundreds of smaller binaries (assuming you execute the large binary several times, rather than have a method for it to execute all tests in a single go).  That point is probably &amp;gt; 100MB for larger systems, but for an embedded system, it could be much smaller.&lt;br /&gt;
&lt;br /&gt;
For Steve's second suggestion, I think my biggest concerns would be how to logically separate out a unit test method without including the test framework (maybe throw it all in there?).  I kinda like the idea of keeping the test inside the libraries, but I'm not sure why -- maybe 'cause I recently spent a few months back in a java world, where it's normal to throw all your unit tests into the same jar for production.  I'm not sure I like that, though.  The overhead of a single function per &amp;quot;module&amp;quot; added to the exports is also unlikely to drastically decrease link-time or run-time performance, too (compared with exporting everything).&lt;br /&gt;
&lt;br /&gt;
=== Improved Patch/Cherry-pick Process ===&lt;br /&gt;
Geoff Thorpe: (a) patches that are not applied/cherry-picked to all the branches they apply to, or (b) applied to more branches than they should be. A complication of (a) is that some patches may need to be reworked in order to apply (or in order to not break binary compatibility of a stable branch). The difficulty of (b) is determining when the nature of the change either breaks binary compatibility or causes some other behavioral deviation that is not in keeping with the &amp;quot;promises&amp;quot; of stable branches.&lt;br /&gt;
&lt;br /&gt;
http://ispras.linuxbase.org/index.php/ABI_compliance_checker&lt;br /&gt;
https://github.com/lvc/abi-compliance-checker/&lt;br /&gt;
&lt;br /&gt;
Geoff on 2014-05-30: ...we might move to a scheme whereby we only maintain one most-recent stable branch for production releases, with snapshots or whatever of the development head. Ie. two branches, one for maximum-compatibility/bug-fixes-only, and the other for more active development. The number of &amp;quot;stable&amp;quot; branches would thus be 1 rather than 'n'. The idea is that we may defer to downstream &amp;quot;slow-moving&amp;quot; users (eg. long-term releases of linux distros) the opportunity to step up and do the work of maintaining (cherry-picking, back-porting, ...) older branches. Ie. what they typically already do in-house, but the opportunity to do it under our roof and thus combine their efforts with any other similarly-interested parties. If there's noone prepared to do that, the logical conclusion is that there is probably no need for it (or so the argument goes).&lt;br /&gt;
&lt;br /&gt;
=== Improve/Standardize Algorithm Testing ===&lt;br /&gt;
Steve Henson: While the algorithms are partly tested I don't think they're anything like comprehensive enough. The way they are handled is also haphazard and spread across multiple tests covering all sorts of odd APIs, some of which are deprecated.&lt;br /&gt;
&lt;br /&gt;
In fact I'd say they're (with the odd exception) an example of how *not* to do things.&lt;br /&gt;
&lt;br /&gt;
Examples rc2test tests RC2 it has various test vectors hard coded inconsistent indentation and use of low level APIs. The rc4test is a similar story and uses a different format to rc2test. The same tale is repeated all over the place with ideatest, rmdtest etc etc.&lt;br /&gt;
&lt;br /&gt;
Then we come to the code which I think is closest to how things should be which is evp_test. It uses the standard high level EVP API the format is consistent (if undocumented) and adding new tests can be done simply by editing a text file.&lt;br /&gt;
&lt;br /&gt;
It currently however only works for some algorithms and the text file format could be better. It currently doesn't handle public key algorithms or test variants of the same algorithm (e.g. AES-NI versus non AES-NI) either.&lt;br /&gt;
&lt;br /&gt;
=== Develop SSL/TLS Stack and Other Tools ===&lt;br /&gt;
Steve Henson: The heartbeat bug is an example where you can perform some testing without a complete SSL/TLS stack. However looking through the code in heartbeat_test.c it uses a lot of functionality which would normally be strictly off-limits for an application.&lt;br /&gt;
&lt;br /&gt;
Some bugs are far more subtle and harder to test. For example some involve doing *almost* everything right and then slipping in some illegal parameter or badly formatted message. If you want to do that in a standalone bit of code you need a near complete SSL/TLS stack.&lt;br /&gt;
&lt;br /&gt;
I can think of a couple of ways to handle that. One is to have some kind of hooks in libssl so testing code can misbehave and send out illegal messages in controlled ways (I had a prototype &amp;quot;bad heartbeat&amp;quot; API which only added a couple of lines to libssl). An alternative would be to write some kind of tiny SSL/TLS code used only by the test programs and carefully tailored to permit such things.&lt;/div&gt;</summary>
		<author><name>Ckomlo</name></author>
	</entry>
</feed>