1 /*
2 * Copyright (c) 2024-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <memory>
16 #include <gtest/gtest.h>
17 #include <fstream>
18
19 #include "cert_dn_utils.h"
20 #include "securec.h"
21 #include "file_utils.h"
22
23 namespace OHOS {
24 namespace SignatureTools {
25
26 class FileUtilsTest : public testing::Test {
27 public:
SetUpTestCase(void)28 static void SetUpTestCase(void)
29 {
30 };
TearDownTestCase()31 static void TearDownTestCase()
32 {
33 };
SetUp()34 void SetUp()
35 {
36 };
TearDown()37 void TearDown()
38 {
39 };
40 };
41
42 const int THREAD_NUMS = 8;
43 const size_t MAX_FILE_SIZE = 1024 * 1024 * 10;
44 const size_t BUFFER_SIZE = 1024 * 128;
45 const int CHMOD = 0777;
46 const size_t MAX_VALUE = 0x80000000LL;
47
48 /**
49 * Generate files for thread pool testing.
50 */
CreateTestFile()51 void CreateTestFile()
52 {
53 (void)mkdir("tmp", CHMOD);
54
55 for (int i = 1; i <= THREAD_NUMS; i++) {
56 std::string fileName = "tmp/tmp-" + std::to_string(i) + ".txt";
57 std::ofstream file(fileName, std::ios::binary);
58 if (!file.is_open()) {
59 printf("open file: %s failed.\n", fileName.c_str());
60 continue;
61 }
62
63 char buffer[BUFFER_SIZE];
64 // The contents of the generated file are all characters '0'
65 (void)memset_s(buffer, sizeof(buffer), '0', sizeof(buffer));
66
67 size_t remaining = MAX_FILE_SIZE;
68 while (remaining > 0) {
69 size_t min = std::min(BUFFER_SIZE, remaining);
70 file.write(buffer, min);
71 if (!file.good()) {
72 printf("write file: %s failed.\n", fileName.c_str());
73 break;
74 }
75
76 remaining -= min;
77 }
78 printf("File %s has been created with %zu bytes.\n", fileName.c_str(), MAX_FILE_SIZE);
79 }
80 }
81
82 /**
83 * Thread pool execution function
84 */
Worker(const std::string & inputFile,const std::string & outputFile,int length)85 int Worker(const std::string& inputFile, const std::string& outputFile, int length)
86 {
87 std::ifstream input(inputFile, std::ios::binary);
88 std::ofstream output(outputFile, std::ios::binary);
89 if (!input) {
90 printf("open file: %s failed.\n", inputFile.c_str());
91 return -1;
92 }
93 if (!output) {
94 printf("open file: %s failed.\n", outputFile.c_str());
95 return -1;
96 }
97
98 int res = FileUtils::WriteInputToOutPut(input, output, length);
99
100 std::thread::id id = std::this_thread::get_id();
101 printf("thread: %u completed: %s -> %s res: %d\n", *(uint32_t*)&id, inputFile.c_str(),
102 outputFile.c_str(), res);
103
104 output.close();
105 input.close();
106 return res;
107 }
108
109 /**
110 * @tc.name: WriteByteToOutFile001
111 * @tc.desc: Test WriteByteToOutFile function for FAIL.
112 * @tc.size: MEDIUM
113 * @tc.type: FUNC
114 * @tc.level Level 1
115 * @tc.require: SR000H63TL
116 */
117 HWTEST_F(FileUtilsTest, WriteByteToOutFile001, testing::ext::TestSize.Level1)
118 {
119 /*
120 * @tc.steps: step1. make the output file is not exist
121 * @tc.expected: step1. failed to get output stream object, the return will be true.
122 */
123 std::vector<int8_t> bytes;
124 std::ofstream output("./utilstmp/signed-file.out", std::ios::binary);
125 bool flag = FileUtils::WriteByteToOutFile(bytes, output);
126 EXPECT_EQ(flag, false);
127 }
128
129 /**
130 * @tc.name: WriteByteToOutFile002
131 * @tc.desc: Test WriteByteToOutFile function for SUCCESS.
132 * @tc.size: MEDIUM
133 * @tc.type: FUNC
134 * @tc.level Level 1
135 * @tc.require: SR000H63TL
136 */
137 HWTEST_F(FileUtilsTest, WriteByteToOutFile002, testing::ext::TestSize.Level1)
138 {
139 std::filesystem::path dir_path("./utils");
140 ASSERT_TRUE(std::filesystem::create_directory(dir_path));
141
142 std::vector<int8_t> bytes;
143 std::ofstream output("./utils/unsigned-file.out", std::ios::binary);
144 bool flag = FileUtils::WriteByteToOutFile(bytes, output);
145 EXPECT_EQ(flag, true);
146 }
147
148 /**
149 * @tc.name: WriteByteToOutFile003
150 * @tc.desc: Test function interface for SUCCESS.
151 * @tc.size: MEDIUM
152 * @tc.type: FUNC
153 * @tc.level Level 1
154 * @tc.require: SR000H63TL
155 */
156 HWTEST_F(FileUtilsTest, WriteByteToOutFile003, testing::ext::TestSize.Level1)
157 {
158 /*
159 * @tc.steps: step1. make the output file is not exist
160 * @tc.expected: step1. failed to get output stream object, the return will be true.
161 */
162 std::string bytes;
163 std::ofstream output("./utilsxxx/signed-file.out", std::ios::binary);
164 bool result = FileUtils::WriteByteToOutFile(bytes, output);
165 EXPECT_EQ(result, false);
166 }
167
168 /**
169 * @tc.name: Write
170 * @tc.desc: Test Write function for FAIL.
171 * @tc.size: MEDIUM
172 * @tc.type: FUNC
173 * @tc.level Level 1
174 * @tc.require: SR000H63TL
175 */
176 HWTEST_F(FileUtilsTest, Write, testing::ext::TestSize.Level1)
177 {
178 /*
179 * @tc.steps: step1. make the output file is not exist
180 * @tc.expected: step1. open output file failed, the return will be IO_ERROR.
181 */
182 std::string str;
183 std::string fileName = "./utilsxxx/signed-file.out";
184 int result = FileUtils::Write(str, fileName);
185 EXPECT_EQ(result, IO_ERROR);
186 }
187
188 /**
189 * @tc.name: Read
190 * @tc.desc: Test Read function for FAIL.
191 * @tc.size: MEDIUM
192 * @tc.type: FUNC
193 * @tc.level Level 1
194 * @tc.require: SR000H63TL
195 */
196 HWTEST_F(FileUtilsTest, Read, testing::ext::TestSize.Level1)
197 {
198 /*
199 * @tc.steps: step1. make the input file is not exist
200 * @tc.expected: step1. open input file failed, the return will be IO_ERROR.
201 */
202 std::string outstr;
203 std::ifstream input("./utilsxxx/unsigned-file.out", std::ios::binary);
204 int result = FileUtils::Read(input, outstr);
205 EXPECT_EQ(result, IO_ERROR);
206 }
207
208 /**
209 * @tc.name: ReadFile
210 * @tc.desc: Test ReadFile function for FAIL.
211 * @tc.size: MEDIUM
212 * @tc.type: FUNC
213 * @tc.level Level 1
214 * @tc.require: SR000H63TL
215 */
216 HWTEST_F(FileUtilsTest, ReadFile, testing::ext::TestSize.Level1)
217 {
218 /*
219 * @tc.steps: step1. make the input file is not exist
220 * @tc.expected: step1. open input file failed, the return will be IO_ERROR.
221 */
222 std::string outstr;
223 std::string fileName = "./utilsxxx/unsigned-file.out";
224 int result = FileUtils::ReadFile(fileName, outstr);
225 EXPECT_EQ(result, IO_ERROR);
226 }
227
228 /**
229 * @tc.name: ReadFileByOffsetAndLength001
230 * @tc.desc: Test ReadFileByOffsetAndLength function for FAIL.
231 * @tc.size: MEDIUM
232 * @tc.type: FUNC
233 * @tc.level Level 1
234 * @tc.require: SR000H63TL
235 */
236 HWTEST_F(FileUtilsTest, ReadFileByOffsetAndLength001, testing::ext::TestSize.Level1)
237 {
238 std::string outstr;
239 std::ifstream input("./utils/unsigned-file.out", std::ios::binary);
240 /*
241 * @tc.steps: step1. make the write size is greater than INT_MAX
242 * @tc.expected: step1. the return will be RET_FAILED.
243 */
244 int result = FileUtils::ReadFileByOffsetAndLength(input, 0, MAX_VALUE, outstr);
245 EXPECT_EQ(result, RET_FAILED);
246 }
247
248 /**
249 * @tc.name: ReadFileByOffsetAndLength002
250 * @tc.desc: Test ReadFileByOffsetAndLength function for FAIL.
251 * @tc.size: MEDIUM
252 * @tc.type: FUNC
253 * @tc.level Level 1
254 * @tc.require: SR000H63TL
255 */
256 HWTEST_F(FileUtilsTest, ReadFileByOffsetAndLength002, testing::ext::TestSize.Level1)
257 {
258 std::string outstr;
259 std::ifstream input("./utils/unsigned-file.out", std::ios::binary);
260 /*
261 * @tc.steps: step1. make the input file is not exist, and the offset is -1
262 * @tc.expected: step1. the input stream is bad, and the offset is error, the return will be IO_ERROR.
263 */
264 int result = FileUtils::ReadFileByOffsetAndLength(input, -1, 32, outstr);
265 EXPECT_EQ(result, IO_ERROR);
266 }
267
268 /**
269 * @tc.name: ReadInputByOffsetAndLength001
270 * @tc.desc: Test ReadInputByOffsetAndLength function for FAIL.
271 * @tc.size: MEDIUM
272 * @tc.type: FUNC
273 * @tc.level Level 1
274 * @tc.require: SR000H63TL
275 */
276 HWTEST_F(FileUtilsTest, ReadInputByOffsetAndLength001, testing::ext::TestSize.Level1)
277 {
278 std::string outstr;
279 std::ifstream input("./utils/unsigned-file.out", std::ios::binary);
280 /*
281 * @tc.steps: step1. make the length is greater than INT_MAX
282 * @tc.expected: step1. Size cannot be greater than Integer max value, the return will be -1.
283 */
284 int result = FileUtils::ReadInputByOffsetAndLength(input, 0, MAX_VALUE, outstr);
285 EXPECT_EQ(result, -1);
286 }
287
288 /**
289 * @tc.name: ReadInputByOffsetAndLength002
290 * @tc.desc: Test ReadInputByOffsetAndLength function for FAIL.
291 * @tc.size: MEDIUM
292 * @tc.type: FUNC
293 * @tc.level Level 1
294 * @tc.require: SR000H63TL
295 */
296 HWTEST_F(FileUtilsTest, ReadInputByOffsetAndLength002, testing::ext::TestSize.Level1)
297 {
298 std::string outstr;
299 /*
300 * @tc.steps: step1. make the input file is not exist
301 * @tc.expected: step1. input error occurred, the return will be -1.
302 */
303 std::ifstream input("./utils/unsigned-filexx.out", std::ios::binary);
304 int result = FileUtils::ReadInputByOffsetAndLength(input, 0, 32, outstr);
305 EXPECT_EQ(result, -1);
306 }
307
308 /**
309 * @tc.name: ReadInputByLength001
310 * @tc.desc: Test ReadInputByLength function for FAIL.
311 * @tc.size: MEDIUM
312 * @tc.type: FUNC
313 * @tc.level Level 1
314 * @tc.require: SR000H63TL
315 */
316 HWTEST_F(FileUtilsTest, ReadInputByLength001, testing::ext::TestSize.Level1)
317 {
318 /*
319 * @tc.steps: step1. make the length is greater than INT_MAX
320 * @tc.expected: step1. Size cannot be greater than Integer max value, the return will be -1.
321 */
322 std::string outstr;
323 std::ifstream input("./utils/unsigned-file.out", std::ios::binary);
324 int result = FileUtils::ReadInputByLength(input, MAX_VALUE, outstr);
325 EXPECT_EQ(result, -1);
326 }
327
328 /**
329 * @tc.name: ReadInputByLength002
330 * @tc.desc: Test ReadInputByLength function for FAIL.
331 * @tc.size: MEDIUM
332 * @tc.type: FUNC
333 * @tc.level Level 1
334 * @tc.require: SR000H63TL
335 */
336 HWTEST_F(FileUtilsTest, ReadInputByLength002, testing::ext::TestSize.Level1)
337 {
338 /*
339 * @tc.steps: step1. make the input file is not exist
340 * @tc.expected: step1. input error occurred, the return will be -1.
341 */
342 std::string outstr;
343 std::ifstream input("./utils/unsigned-filexx.out", std::ios::binary);
344 int result = FileUtils::ReadInputByLength(input, 32, outstr);
345 EXPECT_EQ(result, -1);
346 }
347
348 /**
349 * @tc.name: AppendWriteFileByOffsetToFile001
350 * @tc.desc: Test AppendWriteFileByOffsetToFile function for FAIL.
351 * @tc.size: MEDIUM
352 * @tc.type: FUNC
353 * @tc.level Level 1
354 * @tc.require: SR000H63TL
355 */
356 HWTEST_F(FileUtilsTest, AppendWriteFileByOffsetToFile001, testing::ext::TestSize.Level1)
357 {
358 /*
359 * @tc.steps: step1. make the input file is not exist
360 * @tc.expected: step1. input error occurred, the return will be false.
361 */
362 std::ifstream input("./utils/unsigned-filexx.out", std::ios::binary);
363 std::ofstream output("./utils/signed-file.out", std::ios::binary | std::ios::out);
364 bool result = FileUtils::AppendWriteFileByOffsetToFile(input, output, 0, 32);
365 EXPECT_EQ(result, false);
366 }
367
368 /**
369 * @tc.name: AppendWriteFileByOffsetToFile002
370 * @tc.desc: Test AppendWriteFileByOffsetToFile function for FAIL.
371 * @tc.size: MEDIUM
372 * @tc.type: FUNC
373 * @tc.level Level 1
374 * @tc.require: SR000H63TL
375 */
376 HWTEST_F(FileUtilsTest, AppendWriteFileByOffsetToFile002, testing::ext::TestSize.Level1)
377 {
378 /*
379 * @tc.steps: step1. make the output file is not exist
380 * @tc.expected: step1. output error occurred, the return will be false.
381 */
382 std::ifstream input("./utils/unsigned-file.out", std::ios::binary);
383 std::ofstream output("./utilsxxx/signed-file.out", std::ios::binary);
384 bool result = FileUtils::AppendWriteFileByOffsetToFile(input, output, 0, 32);
385 EXPECT_EQ(result, false);
386 }
387
388 /**
389 * @tc.name: AppendWriteFileByOffsetToFile003
390 * @tc.desc: Test AppendWriteFileByOffsetToFile function for FAIL.
391 * @tc.size: MEDIUM
392 * @tc.type: FUNC
393 * @tc.level Level 1
394 * @tc.require: SR000H63TL
395 */
396 HWTEST_F(FileUtilsTest, AppendWriteFileByOffsetToFile003, testing::ext::TestSize.Level1)
397 {
398 /*
399 * @tc.steps: step1. make the offset is -1
400 * @tc.expected: step1. write error occurred, the return will be false.
401 */
402 std::ifstream input("./utils/unsigned-file.out", std::ios::binary);
403 std::ofstream output("./utils/signed-file.out", std::ios::binary);
404 bool result = FileUtils::AppendWriteFileByOffsetToFile(input, output, -1, 32);
405 EXPECT_EQ(result, false);
406 }
407
408 /**
409 * @tc.name: AppendWriteFileToFile001
410 * @tc.desc: Test AppendWriteFileToFile function for FAIL.
411 * @tc.size: MEDIUM
412 * @tc.type: FUNC
413 * @tc.level Level 1
414 * @tc.require: SR000H63TL
415 */
416 HWTEST_F(FileUtilsTest, AppendWriteFileToFile001, testing::ext::TestSize.Level1)
417 {
418 /*
419 * @tc.steps: step1. make the input file is not exist.
420 * @tc.expected: step1. failed to get input stream object, the return will be false.
421 */
422 std::string inputFile = "./utils/unsigned-filexx.out";
423 std::string outputFile = "./utils/signed-file.out";
424 bool result = FileUtils::AppendWriteFileToFile(inputFile, outputFile);
425 EXPECT_EQ(result, false);
426 }
427
428 /**
429 * @tc.name: AppendWriteFileToFile002
430 * @tc.desc: Test AppendWriteFileToFile function for FAIL.
431 * @tc.size: MEDIUM
432 * @tc.type: FUNC
433 * @tc.level Level 1
434 * @tc.require: SR000H63TL
435 */
436 HWTEST_F(FileUtilsTest, AppendWriteFileToFile002, testing::ext::TestSize.Level1)
437 {
438 /*
439 * @tc.steps: step1. make the output file is not exist.
440 * @tc.expected: step1. failed to get output stream object, the return will be false.
441 */
442 std::string inputFile = "./utils/unsigned-file.out";
443 std::string outputFile = "./utilsxxx/signed-file.out";
444 bool result = FileUtils::AppendWriteFileToFile(inputFile, outputFile);
445 EXPECT_EQ(result, false);
446 }
447
448 /**
449 * @tc.name: AppendWriteByteToFile
450 * @tc.desc: Test AppendWriteByteToFile function for FAIL.
451 * @tc.size: MEDIUM
452 * @tc.type: FUNC
453 * @tc.level Level 1
454 * @tc.require: SR000H63TL
455 */
456 HWTEST_F(FileUtilsTest, AppendWriteByteToFile, testing::ext::TestSize.Level1)
457 {
458 /*
459 * @tc.steps: step1. make the output file is not exist.
460 * @tc.expected: step1. Failed to write data to output stream, the return will be false.
461 */
462 std::string bytes;
463 std::string outputFile = "./utilsxxx/signed-file.out";
464 bool result = FileUtils::AppendWriteByteToFile(bytes, outputFile);
465 EXPECT_EQ(result, false);
466 }
467
468 /**
469 * @tc.name: WriteInputToOutPut001
470 * @tc.desc: Test WriteInputToOutPut function for FAIL.
471 * @tc.size: MEDIUM
472 * @tc.type: FUNC
473 * @tc.level Level 1
474 * @tc.require: SR000H63TL
475 */
476 HWTEST_F(FileUtilsTest, WriteInputToOutPut001, testing::ext::TestSize.Level1)
477 {
478 /*
479 * @tc.steps: step1. make the input file is not exist.
480 * @tc.expected: step1. failed to get input stream object, the return will be false.
481 */
482 std::string inputFile = "./utils/unsigned-filexx.out";
483 std::string outputFile = "./utils/signed-file.out";
484 bool result = FileUtils::WriteInputToOutPut(inputFile, outputFile);
485 EXPECT_EQ(result, false);
486 }
487
488 /**
489 * @tc.name: WriteInputToOutPut002
490 * @tc.desc: Test function interface for SUCCESS.
491 * @tc.size: MEDIUM
492 * @tc.type: FUNC
493 * @tc.level Level 1
494 * @tc.require: SR000H63TL
495 */
496 HWTEST_F(FileUtilsTest, WriteInputToOutPut002, testing::ext::TestSize.Level1)
497 {
498 /*
499 * @tc.steps: step1. make the output file is not exist.
500 * @tc.expected: step1. failed to get output stream object, the return will be false.
501 */
502 std::string inputFile = "./utils/unsigned-file.out";
503 std::string outputFile = "./utilsxxx/signed-file.out";
504 bool result = FileUtils::WriteInputToOutPut(inputFile, outputFile);
505 EXPECT_EQ(result, false);
506 }
507
508 /**
509 * @tc.name: WriteInputToOutPut003
510 * @tc.desc: Test WriteInputToOutPut function for SUCCESS.
511 * @tc.size: MEDIUM
512 * @tc.type: FUNC
513 * @tc.level Level 1
514 * @tc.require: SR000H63TL
515 */
516 HWTEST_F(FileUtilsTest, WriteInputToOutPut003, testing::ext::TestSize.Level1)
517 {
518 std::string inputFile = "./utils/unsigned-file.out";
519 std::string outputFile = "./utils/signed-file.out";
520 bool result = FileUtils::WriteInputToOutPut(inputFile, outputFile);
521 EXPECT_EQ(result, true);
522 }
523
524 /**
525 * @tc.name: IsRunnableFile001
526 * @tc.desc: Test IsRunnableFile function for FAIL.
527 * @tc.size: MEDIUM
528 * @tc.type: FUNC
529 * @tc.level Level 1
530 * @tc.require: SR000H63TL
531 */
532 HWTEST_F(FileUtilsTest, IsRunnableFile001, testing::ext::TestSize.Level1)
533 {
534 /*
535 * @tc.steps: step1. make the file name is empty.
536 * @tc.expected: step1. the return will be false.
537 */
538 std::string fileName;
539 bool result = FileUtils::IsRunnableFile(fileName);
540 EXPECT_EQ(result, false);
541 }
542
543 /**
544 * @tc.name: IsRunnableFile002
545 * @tc.desc: Test IsRunnableFile function for FAIL.
546 * @tc.size: MEDIUM
547 * @tc.type: FUNC
548 * @tc.level Level 1
549 * @tc.require: SR000H63TL
550 */
551 HWTEST_F(FileUtilsTest, IsRunnableFile002, testing::ext::TestSize.Level1)
552 {
553 /*
554 * @tc.steps: step1. make the file name has not dot symbol.
555 * @tc.expected: step1. the return will be false.
556 */
557 std::string fileName = "xxx";
558 bool result = FileUtils::IsRunnableFile(fileName);
559 EXPECT_EQ(result, false);
560 }
561
562 /**
563 * @tc.name: IsRunnableFile003
564 * @tc.desc: Test IsRunnableFile function for FAIL.
565 * @tc.size: MEDIUM
566 * @tc.type: FUNC
567 * @tc.level Level 1
568 * @tc.require: SR000H63TL
569 */
570 HWTEST_F(FileUtilsTest, IsRunnableFile003, testing::ext::TestSize.Level1)
571 {
572 /*
573 * @tc.steps: step1. make the file name is end of xxx
574 * @tc.expected: step1. the return will be false.
575 */
576 std::string fileName = "test.xxx";
577 bool result = FileUtils::IsRunnableFile(fileName);
578 EXPECT_EQ(result, false);
579 }
580
581 /**
582 * @tc.name: DelDir
583 * @tc.desc: Test DelDir function for SUCCESS.
584 * @tc.size: MEDIUM
585 * @tc.type: FUNC
586 * @tc.level Level 1
587 * @tc.require: SR000H63TL
588 */
589 HWTEST_F(FileUtilsTest, DelDir, testing::ext::TestSize.Level1)
590 {
591 std::string fileName = "./utils/testdeldir";
592 FileUtils::DelDir(fileName);
593
594 // create dir and file again
595 std::filesystem::path dir_path(fileName);
596 bool ret = std::filesystem::create_directories(dir_path);
597
598 std::filesystem::path file_path = dir_path / "example.txt";
599 std::ofstream file(file_path, std::ios::binary | std::ios::out);
600 file.close();
601 FileUtils::DelDir(fileName);
602 EXPECT_EQ(ret, true);
603 }
604
605 /**
606 * @tc.name: WriteInputToOutPut
607 * @tc.desc: Test WriteInputToOutPut function for SUCCESS through multithreading.
608 * @tc.size: MEDIUM
609 * @tc.type: FUNC
610 * @tc.level Level 1
611 * @tc.require: SR000H63TL
612 */
613 HWTEST_F(FileUtilsTest, WriteInputToOutPutMultithreadingTest, testing::ext::TestSize.Level1)
614 {
615 CreateTestFile();
616
617 std::vector<std::thread> threads;
618
619 for (int i = 1; i <= THREAD_NUMS; ++i) {
620 std::string inputFile = "tmp/tmp-" + std::to_string(i) + ".txt";
621 std::string outputFile = "tmp/tmp-" + std::to_string(i) + "-copy.txt";
622 auto length = std::filesystem::file_size(inputFile);
623
624 threads.emplace_back(Worker, inputFile, outputFile, length);
625 }
626
627 for (auto& thread : threads) {
628 thread.join();
629 }
630
631 printf("All threads completed.\n");
632 }
633
634 /**
635 * @tc.name: GCheckDn001
636 * @tc.desc: Test GCheckDn001 function for SUCCESS through multithreading.
637 * @tc.size: MEDIUM
638 * @tc.type: FUNC
639 * @tc.level Level 1
640 * @tc.require: SR000H63TL
641 */
642 HWTEST_F(FileUtilsTest, GCheckDn001, testing::ext::TestSize.Level1)
643 {
644 std::vector<std::pair<std::string, std::string>> pairs;
645 pairs.push_back({ "1111", "2222" });
646 int ret = g_checkDn(std::string(","), pairs);
647 EXPECT_NE(ret, 0);
648 }
649
650 /**
651 * @tc.name: GCheckDn002
652 * @tc.desc: Test GCheckDn002 function for SUCCESS through multithreading.
653 * @tc.size: MEDIUM
654 * @tc.type: FUNC
655 * @tc.level Level 1
656 * @tc.require: SR000H63TL
657 */
658 HWTEST_F(FileUtilsTest, GCheckDn002, testing::ext::TestSize.Level1)
659 {
660 std::vector<std::pair<std::string, std::string>> pairs;
661 pairs.push_back({ "1111", "2222" });
662 int ret = g_checkDn(std::string("hello=="), pairs);
663 EXPECT_NE(ret, 0);
664 }
665 } // namespace SignatureTools
666 } // namespace OHOS