{"id":22837429,"url":"https://github.com/hubtou/b2bt","last_synced_at":"2026-05-09T01:09:07.271Z","repository":{"id":57453838,"uuid":"372647818","full_name":"HubTou/b2bt","owner":"HubTou","description":"Back-to-back testing utility","archived":false,"fork":false,"pushed_at":"2021-09-26T07:46:32.000Z","size":178,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T21:48:46.676Z","etag":null,"topics":["command-line-tool","learning-python","learning-unix","pnu-project","python","shell","test-automation","testing","testing-tools","tools","unix","utilities"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HubTou.png","metadata":{"files":{"readme":"README.5.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-31T23:06:10.000Z","updated_at":"2021-09-26T07:45:23.000Z","dependencies_parsed_at":"2022-08-29T10:41:29.131Z","dependency_job_id":null,"html_url":"https://github.com/HubTou/b2bt","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Fb2bt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Fb2bt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Fb2bt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubTou%2Fb2bt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubTou","download_url":"https://codeload.github.com/HubTou/b2bt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413087,"owners_count":20773050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","learning-python","learning-unix","pnu-project","python","shell","test-automation","testing","testing-tools","tools","unix","utilities"],"created_at":"2024-12-12T23:16:50.497Z","updated_at":"2026-05-09T01:09:07.229Z","avatar_url":"https://github.com/HubTou.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# B2BT(5)\n\n## NAME\nb2bt XML files - back-to-back testing utility's format for test suites\n\n## DESCRIPTION\nThe **b2bt** utility aims to automate:\n* back-to-back testing (testing a command-line utility against another implementation)\n* non regression testing (testing a command-line utility against a previous version)\n\nIt processes one or more [XML](https://en.wikipedia.org/wiki/XML) files describing the test suite for a command-line utility,\nwith its different test cases, execute the 2 commands versions and report potential\ndifferences (on return codes, standard output, standard error output, plus custom post\nprocessing output in order to check other kind of impacts, on file systems, execution time, etc.).\n\nIn a test suite it is possible to specify:\n* optional shell commands to execute before the test, typically to setup the test environment\n  in an automatically generated test sub directory. We call this \"pre\" commands.\n* optional standard input to be injected in the command tested\n* mandatory one line shell command-line for the command to be tested\n* optional shell commands to execute after the test, typically to analyze the tested command\n  impact on the test environment. The output of these \"post\" commands is captured before\n  automatic removal of the test sub directory\n\nEach test case can have a name and a potential timeout (in seconds or fraction of seconds).\n\nA b2bt XML file starts with a line indicating the XML version we use:\n```XML\n\u003c?xml version=\"1.0\"?\u003e\n```\n\nThen, all the rest of the file is enclosed between 1 test-suite pair of tags: \n```XML\n\u003ctest-suite program=\"COMMAND\" processor=\"b2bt B2BT_VERSION\" ID=\"@(#) $Id: COMMAND.xml - back to back test suite for COMMAND vVERSION (DATE) by AUTHOR $\"\u003e\n\u003c/test-suite\u003e\n```\nWhere:\n* **COMMAND** is the name of the command to be tested\n* **VERSION** is the version of the test suite\n* **DATE** is the date of last modification to the file\n* **AUTHOR** is the test suite author's name\n* **B2BT_VERSION** is the minimal version required of **b2bt** required to process this file, or 1.0.0 if missing\n\nYou can then have 1 or more test-cases enclosed between test-case pair of tags:\n```XML\n\u003ctest-case name=\"CASE_NAME\" timeout=\"TIMEOUT\"\u003e\n  \u003ccmd\u003e\n    COMMAND\n  \u003c/cmd\u003e\n\u003c/test-case\u003e\n```\nWhere:\n* The **name** attribute is optional but recommended. If you don't provide it, the test will be referred to by its order rank in the file (starting at 1)\n* The **timeout** attribute is optional and it's recommended NOT to use it, unless you have a good reason to do so. It takes a positive value, with an eventual decimal part, expressed in seconds. Whatever the Locale you are using, the decimal separator is the \".\" character\n* **CASE_NAME** is a short string describing the test case\n* **COMMAND** is the command to be shell executed:\n  * the **cmd** tag expects exactly one line. Leading or trailing spaces and newline characters are stripped unless enclosed between double quotes\n  * the command itself must be pathless. b2bt will replace the first occurrence it founds with the absolute path of the original or new command to be tested\n  * the command is executed by a Shell. Its output can be piped to another command or redirected to a file, and it can be prefixed by environment variables definition\n* There are 2 characters that you must escape in all XML tag contents:\n  * The ampersand (\u0026) is to be replaced by \u0026amp;amp;\n  * The \"less than\" operator (\u003c) is to be replaced by \u0026amp;lt;\n* Also remember that, at least, the [predefined XML entities](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML) will be replaced in your tag contents. The 2 previous ones, plus:\n  * \u0026amp;quot; for the quote (\")\n  * \u0026amp;apos; for the apostrophe (')\n  * \u0026amp;gt; for the \"greater than\" operator (\u003e)\n\nApart from the mandatory **cmd** tags, a test-case can also include the following optional tags:\n```XML\n\u003ctest-case name=\"CASE_NAME\" timeout=\"TIMEOUT\"\u003e\n  \u003cpre\u003e\n    PRE_COMMANDS\n  \u003c/pre\u003e \n  \u003cstdin\u003e\n    INPUT_LINES\n  \u003c/stdin\u003e \n  \u003ccmd\u003e\n    COMMAND\n  \u003c/cmd\u003e\n  \u003cpost\u003e\n    POST_COMMANDS\n  \u003c/post\u003e \n\u003c/test-case\u003e\n```\nWhere:\n* **PRE_COMMANDS** is 0 to N lines of commands to be shell executed before the command to be tested:\n  * These commands are independent from each other. This is not a shell script! Peculiarly, you can't use \"here documents\" or environment variables definition affecting succeeding lines...\n  * This section is intended to create any files or directories with associated content needed for the test case. It will be executed twice, for the original and the new command, so that each one runs in a fresh environment\n* **POST_COMMANDS** does the same, except its commands are executed after the command to be tested and their output is collected for later comparisons:\n  * This section is intended to check additional effects of the command tested, for example in terms of files/directories creation/modification/deletion, execution duration, etc.\n  * The temporary directory where the test happens will automatically be cleaned, and this doesn't need to be addressed by the user\n* **INPUT_LINES** is 0 to N lines of text to be injected as standard input into the command to be tested. Again, leading or trailing spaces and newline characters are stripped\n\nIf you want portable test suites, please make sure that all commands you use\nin the pre, cmd and post sections are available in all the operating systems\nthat you target...\n\n## EXAMPLES\nA minimal test suite would be:\n```XML\n\u003c?xml version=\"1.0\"?\u003e\n\u003ctest-suite program=\"basename\" processor=\"b2bt\" ID=\"@(#) $Id: basename.xml - back to back test suite for basename v1.0.0 (May 30, 2021) by Hubert Tournier $\"\u003e\n  \u003ctest-case name=\"Typical usage - removing directories and file extension\"\u003e\n    \u003ccmd\u003e\n      basename /directory1/directory2/file1.ext .ext\n    \u003c/cmd\u003e\n  \u003c/test-case\u003e\n\u003c/test-suite\u003e\n```\n\nAnother more sophisticated test suite would be:\n```XML\n\u003c?xml version=\"1.0\"?\u003e\n\u003ctest-suite program=\"cat\" processor=\"b2bt\" ID=\"@(#) $Id: cat.xml - back to back test suite for cat v1.0.0 (May 30, 2021) by Hubert Tournier $\"\u003e\n  \u003ctest-case name=\"Concatenate 2 files\"\u003e\n    \u003cpre\u003e\n      printf \"%s\\n%s\\n%s\\n\" a b c \u003e 1\n      printf \"%s\\n%s\\n%s\\n\" d e f \u003e 2\n    \u003c/pre\u003e\n    \u003ccmd\u003e\n      cat 1 2\n    \u003c/cmd\u003e\n    \u003cpost\u003e\n     find .\n     echo\n     cat 1\n     echo\n     cat 2\n    \u003c/post\u003e\n  \u003c/test-case\u003e\n\n  \u003ctest-case name=\"Basic filter - process standard input\"\u003e\n    \u003cstdin\u003e\n      a\n      b\n      c\n    \u003c/stdin\u003e\n    \u003ccmd\u003e\n      cat\n    \u003c/cmd\u003e\n  \u003c/test-case\u003e\n\u003c/test-suite\u003e\n```\n\n## SEE ALSO\n[b2bt(1)](https://github.com/HubTou/b2bt/blob/main/README.md)\n\n## HISTORY\nThese files were made for the [PNU project](https://github.com/HubTou/PNU)\nin order to test the rewritten commands against the installed ones.\n\nThis project will provide [b2bt test files for the usual POSIX and FreeBSD commands](https://github.com/HubTou/PNU/tree/main/tests).\n\n## AUTHORS\n[Hubert Tournier](https://github.com/HubTou)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubtou%2Fb2bt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhubtou%2Fb2bt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubtou%2Fb2bt/lists"}