文章目录
- openssl3.2 - 测试程序的学习 - test\sanitytest.c
- 概述
- 笔记
- 添加好实现的工程
- 效果
- END
openssl3.2 - 测试程序的学习 - test\sanitytest.c
概述
openssl3.2 - 测试程序的学习
重建工程参考 makefile, 将该加的实现加入vs2019工程, 不能无脑添加, 否则编译不过.
这个工程是基础测试(数据类型啥的), 没学到东西.
笔记
从makefile中找到的实现添加线索:
/* Get current time */
OSSL_TIME ossl_time_now(void);test\sanitytest-bin-sanitytest.obj: test\sanitytest.c
test\sanitytest.exe: test\sanitytest-bin-sanitytest.obj test\libtestutil.lib libcrypto_static.libtest\libtestutil.lib: apps\lib\libtestutil-lib-opt.obj
apps\lib\libtestutil-lib-win32_init.obj
test\testutil\libtestutil-lib-apps_shims.obj test\testutil\libtestutil-lib-basic_output.obj test\testutil\libtestutil-lib-cb.obj test\testutil\libtestutil-lib-driver.obj test\testutil\libtestutil-lib-fake_random.obj test\testutil\libtestutil-lib-format_output.obj test\testutil\libtestutil-lib-load.obj test\testutil\libtestutil-lib-main.obj test\testutil\libtestutil-lib-options.obj test\testutil\libtestutil-lib-output.obj test\testutil\libtestutil-lib-provider.obj test\testutil\libtestutil-lib-random.obj test\testutil\libtestutil-lib-stanza.obj test\testutil\libtestutil-lib-test_cleanup.obj test\testutil\libtestutil-lib-test_options.obj test\testutil\libtestutil-lib-tests.obj test\testutil\libtestutil-lib-testutil_init.obj$(AR) $(ARFLAGS) $(AROUTFLAG)test\libtestutil.lib @<<
apps\lib\libtestutil-lib-opt.obj
apps\lib\libtestutil-lib-win32_init.obj
test\testutil\libtestutil-lib-apps_shims.obj
test\testutil\libtestutil-lib-basic_output.obj
test\testutil\libtestutil-lib-cb.obj
test\testutil\libtestutil-lib-driver.obj
test\testutil\libtestutil-lib-fake_random.obj
test\testutil\libtestutil-lib-format_output.obj
test\testutil\libtestutil-lib-load.obj
test\testutil\libtestutil-lib-main.obj
test\testutil\libtestutil-lib-options.obj
test\testutil\libtestutil-lib-output.obj
test\testutil\libtestutil-lib-provider.obj
test\testutil\libtestutil-lib-random.obj
test\testutil\libtestutil-lib-stanza.obj
test\testutil\libtestutil-lib-test_cleanup.obj
test\testutil\libtestutil-lib-test_options.obj
test\testutil\libtestutil-lib-tests.obj
test\testutil\libtestutil-lib-testutil_init.obj
<<
apps\lib\libtestutil-lib-opt.obj: apps\lib\opt.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "apps\lib\opt.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "apps\lib\opt.c" > apps\lib\libtestutil-lib-opt.d 2>&1"
apps\lib\libtestutil-lib-win32_init.obj: apps\lib\win32_init.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "apps\lib\win32_init.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "apps\lib\win32_init.c" > apps\lib\libtestutil-lib-win32_init.d 2>&1"
test\testutil\libtestutil-lib-apps_shims.obj: test\testutil\apps_shims.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\apps_shims.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\apps_shims.c" > test\testutil\libtestutil-lib-apps_shims.d 2>&1"
test\testutil\libtestutil-lib-basic_output.obj: test\testutil\basic_output.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\basic_output.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\basic_output.c" > test\testutil\libtestutil-lib-basic_output.d 2>&1"
test\testutil\libtestutil-lib-cb.obj: test\testutil\cb.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\cb.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\cb.c" > test\testutil\libtestutil-lib-cb.d 2>&1"
test\testutil\libtestutil-lib-driver.obj: test\testutil\driver.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\driver.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\driver.c" > test\testutil\libtestutil-lib-driver.d 2>&1"
test\testutil\libtestutil-lib-fake_random.obj: test\testutil\fake_random.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\fake_random.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\fake_random.c" > test\testutil\libtestutil-lib-fake_random.d 2>&1"
test\testutil\libtestutil-lib-format_output.obj: test\testutil\format_output.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\format_output.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\format_output.c" > test\testutil\libtestutil-lib-format_output.d 2>&1"
test\testutil\libtestutil-lib-load.obj: test\testutil\load.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\load.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\load.c" > test\testutil\libtestutil-lib-load.d 2>&1"
test\testutil\libtestutil-lib-main.obj: test\testutil\main.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\main.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\main.c" > test\testutil\libtestutil-lib-main.d 2>&1"
test\testutil\libtestutil-lib-options.obj: test\testutil\options.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\options.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\options.c" > test\testutil\libtestutil-lib-options.d 2>&1"
test\testutil\libtestutil-lib-output.obj: test\testutil\output.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\output.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\output.c" > test\testutil\libtestutil-lib-output.d 2>&1"
test\testutil\libtestutil-lib-provider.obj: test\testutil\provider.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\provider.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\provider.c" > test\testutil\libtestutil-lib-provider.d 2>&1"
test\testutil\libtestutil-lib-random.obj: test\testutil\random.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\random.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\random.c" > test\testutil\libtestutil-lib-random.d 2>&1"
test\testutil\libtestutil-lib-stanza.obj: test\testutil\stanza.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\stanza.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\stanza.c" > test\testutil\libtestutil-lib-stanza.d 2>&1"
test\testutil\libtestutil-lib-test_cleanup.obj: test\testutil\test_cleanup.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\test_cleanup.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\test_cleanup.c" > test\testutil\libtestutil-lib-test_cleanup.d 2>&1"
test\testutil\libtestutil-lib-test_options.obj: test\testutil\test_options.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\test_options.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\test_options.c" > test\testutil\libtestutil-lib-test_options.d 2>&1"
test\testutil\libtestutil-lib-tests.obj: test\testutil\tests.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\tests.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\tests.c" > test\testutil\libtestutil-lib-tests.d 2>&1"
test\testutil\libtestutil-lib-testutil_init.obj: test\testutil\testutil_init.c$(CC) $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) -c $(COUTFLAG)$@ "test\testutil\testutil_init.c"cmd /C "$(CC) /Zs /showIncludes $(LIB_CFLAGS) -I"include" -I"apps\include" -I"." $(LIB_CPPFLAGS) "test\testutil\testutil_init.c" > test\testutil\libtestutil-lib-testutil_init.d 2>&1"
添加好实现的工程
自己实现一个 ossl_time_now(), 否则编译不过.
只有测试工程在用 ossl_time_now(). openssl.exe工程没用这个东西.
static int test_sanity_memcmp(void)
{// 7return CRYPTO_memcmp("ab", "cd", 2);
}/* Get current time */
OSSL_TIME ossl_time_now(void)
{OSSL_TIME _ossl_time;_ossl_time.t = GetTickCount64();return _ossl_time;
}static int test_sanity_sleep(void)
{
openssl自己实现了一套测试框架
int setup_tests(void)
{ADD_TEST(test_sanity_null_zero);ADD_TEST(test_sanity_enum_size);ADD_TEST(test_sanity_twos_complement);ADD_TEST(test_sanity_sign);ADD_TEST(test_sanity_unsigned_conversion);ADD_TEST(test_sanity_range);ADD_TEST(test_sanity_memcmp);ADD_TEST(test_sanity_sleep);return 1;
}
因为重建的工程路径和openssl工程目录不同, 有些实现的头文件包含路径, 可以自己改一下.
效果
自己搭建的工程, 进行时间测试时报错, 不过无所谓(不关心).
报错原因是ossl_time_now()实现的不合适.