public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* ECC: main function entry point in host-based unit tests
@ 2020-09-25  2:38 Bret Barkelew
  2020-09-25  7:24 ` 回复: [edk2-devel] " gaoliming
  2020-09-25  7:53 ` Laszlo Ersek
  0 siblings, 2 replies; 3+ messages in thread
From: Bret Barkelew @ 2020-09-25  2:38 UTC (permalink / raw)
  To: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

ERROR - EFI coding style error
ERROR - *Error code: 7001
ERROR - *There should be no use of int, unsigned, char, void, long in any .c, .h or .asl files
ERROR - *file: //home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.c
ERROR - *Line number: 763
ERROR - *[main] Return type int
ERROR -
ERROR - EFI coding style error
ERROR - *Error code: 8006
ERROR - *Function name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters
ERROR - *file: //home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.c
ERROR - *Line number: 2253
ERROR - *The function name [main] does not follow the rules

Currently, the host-based unit tests are using a standard C entry point:
int
main ()

That’s going to break both of these.

Another thing to override/figure out for host-based tests

- Bret


[-- Attachment #2: Type: text/html, Size: 2805 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 回复: [edk2-devel] ECC: main function entry point in host-based unit tests
  2020-09-25  2:38 ECC: main function entry point in host-based unit tests Bret Barkelew
@ 2020-09-25  7:24 ` gaoliming
  2020-09-25  7:53 ` Laszlo Ersek
  1 sibling, 0 replies; 3+ messages in thread
From: gaoliming @ 2020-09-25  7:24 UTC (permalink / raw)
  To: devel, bret.barkelew

[-- Attachment #1: Type: text/plain, Size: 1644 bytes --]

Bret:

 ECC mainly checks the firmware source coding style. Host based unit test
code may follow the different rule. I suggest to ignore ECC check result for
them. The ignored file or directory can be added into the Package level
ci.yaml file.

 

Thanks

Liming

发件人: bounce+27952+65601+4905953+8761045@groups.io
<bounce+27952+65601+4905953+8761045@groups.io> 代表 Bret Barkelew via
groups.io
发送时间: 2020年9月25日 10:39
收件人: devel@edk2.groups.io
主题: [edk2-devel] ECC: main function entry point in host-based unit tests

 

ERROR - EFI coding style error

ERROR - *Error code: 7001

ERROR - *There should be no use of int, unsigned, char, void, long in any
.c, .h or .asl files

ERROR - *file:
//home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLi
b/VariablePolicyUnitTest/VariablePolicyUnitTest.c

ERROR - *Line number: 763

ERROR - *[main] Return type int

ERROR - 

ERROR - EFI coding style error

ERROR - *Error code: 8006

ERROR - *Function name does not follow the rules: 1. First character should
be upper case 2. Must contain lower case characters 3. No white space
characters

ERROR - *file:
//home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLi
b/VariablePolicyUnitTest/VariablePolicyUnitTest.c

ERROR - *Line number: 2253

ERROR - *The function name [main] does not follow the rules

 

Currently, the host-based unit tests are using a standard C entry point:

int

main ()

 

That’s going to break both of these.

 

Another thing to override/figure out for host-based tests 

 

- Bret 

 




[-- Attachment #2: Type: text/html, Size: 6028 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] ECC: main function entry point in host-based unit tests
  2020-09-25  2:38 ECC: main function entry point in host-based unit tests Bret Barkelew
  2020-09-25  7:24 ` 回复: [edk2-devel] " gaoliming
@ 2020-09-25  7:53 ` Laszlo Ersek
  1 sibling, 0 replies; 3+ messages in thread
From: Laszlo Ersek @ 2020-09-25  7:53 UTC (permalink / raw)
  To: devel, bret.barkelew

On 09/25/20 04:38, Bret Barkelew via groups.io wrote:
> ERROR - EFI coding style error
> ERROR - *Error code: 7001
> ERROR - *There should be no use of int, unsigned, char, void, long in any .c, .h or .asl files
> ERROR - *file: //home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.c
> ERROR - *Line number: 763
> ERROR - *[main] Return type int
> ERROR -
> ERROR - EFI coding style error
> ERROR - *Error code: 8006
> ERROR - *Function name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters
> ERROR - *file: //home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.c
> ERROR - *Line number: 2253
> ERROR - *The function name [main] does not follow the rules
> 
> Currently, the host-based unit tests are using a standard C entry point:
> int
> main ()

"int main()" is not the standard C entry point. Two prototypes for main() are standard:

int main(void);
int main(int argc, char *argv[]);

where
- "int" may be replaced with a typedef name that's defined as "int",
- and *argv[] may be spelled as **argv too.


... Of course, this doesn't address your main point.

ECC#7001 can be suppressed perhaps if you use INT32 rather than "int".

ECC#8006 can be suppressed perhaps with a macro that expands to "main".


Another -- likely better -- idea:

(1) replace the current main() function prototype with

    INT32
    UnitTestMain (
      IN INT32 ArgC,
      IN UINT8 **ArgV
      );

(2) Introduce

  MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/UnitTestMain.h

such that it only declare the above prototype.

(3) Introduce

  MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/UnitTestEntry.c

with the following contents:

  #include "UnitTestMain.h"

  int main(int argc, char **argv)
  {
    return UnitTestMain(argc, (UINT8 **)argv);
  }

(4) List both new source files in

  MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.inf

in the [Sources] section.

(5) Add

  MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/UnitTestEntry.c

to "EccCheck.IgnoreFiles" in "MdeModulePkg/MdeModulePkg.ci.yaml".

Thanks
Laszlo




> 
> That’s going to break both of these.
> 
> Another thing to override/figure out for host-based tests
> 
> - Bret
> 
> 
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-25  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-25  2:38 ECC: main function entry point in host-based unit tests Bret Barkelew
2020-09-25  7:24 ` 回复: [edk2-devel] " gaoliming
2020-09-25  7:53 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox