1 /*
2 * Copyright (C) 2025 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 "functionalext.h"
16 #include "common.h"
17
18
CrossTests_CheckSources()19 static void CrossTests_CheckSources() {
20 EXPECT_STREQ(__func__, "a.c", strA);
21 EXPECT_STREQ(__func__, "b.c", strB);
22 }
23
CrossTests_CheckMessages()24 static void CrossTests_CheckMessages() {
25 EXPECT_STREQ(__func__, "message from lib A!", msgA);
26 EXPECT_STREQ(__func__, "message from lib B!", msgB);
27 }
28
CrossTests_TestSumF1F2()29 static void CrossTests_TestSumF1F2() {
30 int sum = 0;
31 const int countRuns = 1000000;
32 for (size_t i = 0; i < countRuns; i++)
33 sum += f1();
34 EXPECT_EQ(__func__, 3000000, sum);
35
36 for (size_t i = 0; i < countRuns; i++)
37 sum += f2();
38 EXPECT_EQ(__func__, 7000000, sum);
39 }
40
main(int argc,char ** argv)41 int main(int argc, char **argv) {
42 printf("Hello! This test contains libs built from sources: ");
43 const char *sources[] = {strA, strB};
44 const int countSources = sizeof(sources) / sizeof(sources[0]);
45 for (size_t i = 0; i < countSources; i++)
46 printf("%s ", sources[i]);
47 printf("\n");
48
49 printf("Test print calls in libs: \n");
50 testPrintA();
51 testPrintB();
52
53 testPrintMessageAfromA();
54 testPrintMessageBfromB();
55
56 testPrintMessageAfromB();
57 testPrintMessageBfromA();
58
59 CrossTests_CheckSources();
60 CrossTests_CheckMessages();
61 CrossTests_TestSumF1F2();
62 return t_status;
63 }