fix: 修复测试用例中部分测试内容硬编码的问题

【背景】
A核测试用例中有一些敏感字符串需要修改

【修改方案】
将敏感的字符串改为随机生成

【影响】
对现有的产品编译不会有影响。

re #I5ALBS

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib9b023ace6be1d58248c993f7b9919a96afbea96
This commit is contained in:
yinjiaming
2022-06-07 08:08:51 +00:00
parent fa6b2d352c
commit 19553f73e1
6 changed files with 98 additions and 23 deletions
@@ -32,18 +32,36 @@
#include <libintl.h>
#include <locale.h>
const int domain_name_length = 10;
const int buffer_size = 50;
static UINT32 testcase(VOID)
{
char *s = "";
char domain[buffer_size], tmp[domain_name_length];
srand(time(NULL));
for (int i = 0, r = 0; i < domain_name_length; i++) {
r = rand() % 36; // 36: 0-9 and a-z
if (r < 10) { // 10: 0-9
tmp[i] = '0' + r;
} else {
tmp[i] = 'a' + r;
}
}
int ret = sprintf_s(domain, sizeof(domain), "www.%s.com", tmp);
if (ret == 0) {
printf("sprinf_s failed\n");
return LOS_NOK;
}
setlocale(LC_ALL, "");
textdomain("gettext_demo");
bindtextdomain("gettext_demo", ".");
bind_textdomain_codeset("gettext_demo", "UTF-8");
printf(dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES));
printf(dcgettext(domain, "TestString1\n", LC_MESSAGES));
s = dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES);
s = dcgettext(domain, "TestString1\n", LC_MESSAGES);
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
setlocale(LC_ALL, "C");
@@ -30,7 +30,7 @@
*/
#include "It_test_sys.h"
#define TEST_PASSWORD (char *)"test1234"
const int password_length = 10;
static UINT32 TestCase(VOID)
{
@@ -39,14 +39,24 @@ static UINT32 TestCase(VOID)
char *key = NULL;
char slat[2];
int ret;
char test_password[password_length];
srand(time(NULL));
for (int i = 0, r = 0; i < password_length; i++) {
r = rand() % 36; // 36: 0-9 and a-z
if (r < 10) { // 10: 0-9
test_password[i] = '0' + r;
} else {
test_password[i] = 'a' + r;
}
}
key = TEST_PASSWORD;
key = test_password;
slat[0] = key[0];
slat[1] = key[1];
passwd1 = crypt(key, slat);
ICUNIT_GOTO_NOT_EQUAL(passwd1, NULL, passwd1, EXIT);
key = TEST_PASSWORD;
key = test_password;
slat[0] = passwd1[0];
slat[1] = passwd1[1];
passwd2 = crypt(key, slat);