! * \brief regTestWriteDataAndCheck() * * \param[in] rp regtest parameters * \param[in] data to be written * \param[in] size of data to be written * \param[in] ext filename extension (e.g.: "ba", "pta") * \return 0 if OK, 1 on error a failure in comparison is not an error * * * Notes: * (1) This function makes it easy to write data in a numbered
| 767 | * </pre> |
| 768 | */ |
| 769 | l_int32 |
| 770 | regTestWriteDataAndCheck(L_REGPARAMS *rp, |
| 771 | void *data, |
| 772 | size_t nbytes, |
| 773 | const char *ext) |
| 774 | { |
| 775 | char namebuf[256]; |
| 776 | |
| 777 | PROCNAME("regTestWriteDataAndCheck"); |
| 778 | |
| 779 | if (!rp) |
| 780 | return ERROR_INT("rp not defined", procName, 1); |
| 781 | if (!data || nbytes == 0) { |
| 782 | rp->success = FALSE; |
| 783 | return ERROR_INT("data not defined or size == 0", procName, 1); |
| 784 | } |
| 785 | |
| 786 | /* Generate the local file name */ |
| 787 | snprintf(namebuf, sizeof(namebuf), "/tmp/lept/regout/%s.%02d.%s", |
| 788 | rp->testname, rp->index + 1, ext); |
| 789 | |
| 790 | /* Write the local file */ |
| 791 | l_binaryWrite(namebuf, "w", data, nbytes); |
| 792 | |
| 793 | /* Either write the golden file ("generate") or check the |
| 794 | local file against an existing golden file ("compare") */ |
| 795 | regTestCheckFile(rp, namebuf); |
| 796 | return 0; |
| 797 | } |
| 798 | |
| 799 | |
| 800 | /*! |
nothing calls this directly
no test coverage detected