Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: astyle fix #7605

Merged
merged 2 commits into from
Aug 6, 2018
Merged

tests: astyle fix #7605

merged 2 commits into from
Aug 6, 2018

Conversation

0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented Jul 26, 2018

All tests should now comply to our coding standard

Description

Run astyle for all test files (TESTS/*)

I've noticed that inlined assembly might be broken, will test locally and fix (astyle should ignore inline assembly as such change as indentation there can lead to a broken code).

Pull request type

[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@0xc0170
Copy link
Contributor Author

0xc0170 commented Jul 27, 2018

Rebased, fixed one issue with flash hal test, compilation locally OK

/* 32 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 },
/* 33 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 },
/* 34 */{ {POLY_32BIT_ANSI , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 },
/* 00 */{ {POLY_7BIT_SD, 7, 0x00000000, 0x00000000, false, false}, 0xEA },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format of test cases array has been changed and and readability has been decreased.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can see that astyle removed spaces after macros (true/false including) but not after the numbers). I would completely remove those spaces there and just align it vertically as it is (one empty line between each group).

/* 42 */{ {POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8 },
to
/* 42 */{{POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8},

We can turn off style checking for these cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed now, I removed the spaces, should look now good as it is.

All tests should comply to our coding standard now
@0xc0170
Copy link
Contributor Author

0xc0170 commented Aug 3, 2018

Rebased, please review

@0xc0170
Copy link
Contributor Author

0xc0170 commented Aug 3, 2018

Coding style check OK for all changed files here 🙌

@mprse
Copy link
Contributor

mprse commented Aug 3, 2018

IMAO readability of the original version is still better. Maybe it would be good to make some exception for such tables, since readability is here the most important. In this case it is not so bad, but if length of input values was more diverse, it would be much harder to read this.

Original:

    TEST_CASE local_test_cases[] = {
        /* Predefined polynomials. */
/* 00 */{ {POLY_7BIT_SD     ,  7, 0x00000000, 0x00000000, false, false}, 0xEA       },
/* 01 */{ {POLY_7BIT_SD     ,  7, 0x0000007F, 0x00000000, false, false}, 0xA0       },
/* 02 */{ {POLY_7BIT_SD     ,  7, 0x0000002B, 0x00000000, false, false}, 0x74       },
/* 03 */{ {POLY_7BIT_SD     ,  7, 0x00000000, 0x0000007F, false, false}, 0x95       },
/* 04 */{ {POLY_7BIT_SD     ,  7, 0x00000000, 0x0000002B, false, false}, 0xC1       },
/* 05 */{ {POLY_7BIT_SD     ,  7, 0x00000000, 0x00000000, true , false}, 0xA4       },
/* 06 */{ {POLY_7BIT_SD     ,  7, 0x00000000, 0x00000000, false, true }, 0x57       },


/* 07 */{ {POLY_8BIT_CCITT  ,  8, 0x00000000, 0x00000000, false, false}, 0xF4       },
/* 08 */{ {POLY_8BIT_CCITT  ,  8, 0x000000FF, 0x00000000, false, false}, 0xFB       },
/* 09 */{ {POLY_8BIT_CCITT  ,  8, 0x000000AB, 0x00000000, false, false}, 0x87       },
/* 10 */{ {POLY_8BIT_CCITT  ,  8, 0x00000000, 0x000000FF, false, false}, 0x0B       },
/* 11 */{ {POLY_8BIT_CCITT  ,  8, 0x00000000, 0x000000AB, false, false}, 0x5F       },
/* 12 */{ {POLY_8BIT_CCITT  ,  8, 0x00000000, 0x00000000, true , false}, 0x04       },
/* 13 */{ {POLY_8BIT_CCITT  ,  8, 0x00000000, 0x00000000, false, true }, 0x2F       },


/* 14 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, false, false}, 0x31C3     },
/* 15 */{ {POLY_16BIT_CCITT , 16, 0x0000FFFF, 0x00000000, false, false}, 0x29B1     },
/* 16 */{ {POLY_16BIT_CCITT , 16, 0x0000ABAB, 0x00000000, false, false}, 0x7D70     },
/* 17 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x0000FFFF, false, false}, 0xCE3C     },
/* 18 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x0000ABAB, false, false}, 0x9A68     },
/* 19 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, true , false}, 0x9184     },
/* 20 */{ {POLY_16BIT_CCITT , 16, 0x00000000, 0x00000000, false, true }, 0xC38C     },


/* 21 */{ {POLY_16BIT_IBM   , 16, 0x00000000, 0x00000000, false, false}, 0xFEE8     },
/* 22 */{ {POLY_16BIT_IBM   , 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7     },
/* 23 */{ {POLY_16BIT_IBM   , 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887     },
/* 24 */{ {POLY_16BIT_IBM   , 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117     },
/* 25 */{ {POLY_16BIT_IBM   , 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543     },
/* 26 */{ {POLY_16BIT_IBM   , 16, 0x00000000, 0x00000000, true , false}, 0xBCDD     },
/* 27 */{ {POLY_16BIT_IBM   , 16, 0x00000000, 0x00000000, false, true }, 0x177F     },


/* 28 */{ {POLY_32BIT_ANSI  , 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F },
/* 29 */{ {POLY_32BIT_ANSI  , 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 },
/* 30 */{ {POLY_32BIT_ANSI  , 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA },
/* 31 */{ {POLY_32BIT_ANSI  , 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 },
/* 32 */{ {POLY_32BIT_ANSI  , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 },
/* 33 */{ {POLY_32BIT_ANSI  , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 },
/* 34 */{ {POLY_32BIT_ANSI  , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 },


        /* Not-predefined polynomials. */
/* 35 */{ {POLY_8BIT_MAXIM  ,  8, 0x00000000, 0x00000000, false, false}, 0xA2       },
/* 36 */{ {POLY_8BIT_MAXIM  ,  8, 0x000000FF, 0x00000000, false, false}, 0xF7       },
/* 37 */{ {POLY_8BIT_MAXIM  ,  8, 0x000000AB, 0x00000000, false, false}, 0x71       },
/* 38 */{ {POLY_8BIT_MAXIM  ,  8, 0x00000000, 0x000000FF, false, false}, 0x5D       },
/* 39 */{ {POLY_8BIT_MAXIM  ,  8, 0x00000000, 0x000000AB, false, false}, 0x09       },
/* 40 */{ {POLY_8BIT_MAXIM  ,  8, 0x00000000, 0x00000000, true , false}, 0x85       },
/* 41 */{ {POLY_8BIT_MAXIM  ,  8, 0x00000000, 0x00000000, false, true }, 0x45       },


/* 42 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, false, false}, 0xFEE8     },
/* 43 */{ {POLY_16BIT_MAXIM , 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7     },
/* 44 */{ {POLY_16BIT_MAXIM , 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887     },
/* 45 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117     },
/* 46 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543     },
/* 47 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, true , false}, 0xBCDD     },
/* 48 */{ {POLY_16BIT_MAXIM , 16, 0x00000000, 0x00000000, false, true }, 0x177F     },


/* 49 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F },
/* 50 */{ {POLY_32BIT_POSIX , 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7 },
/* 51 */{ {POLY_32BIT_POSIX , 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA },
/* 52 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680 },
/* 53 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4 },
/* 54 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, true , false}, 0x11B4BFB4 },
/* 55 */{ {POLY_32BIT_POSIX , 32, 0x00000000, 0x00000000, false, true }, 0xFE918591 },
    };

Fixed:

TEST_CASE local_test_cases[] = {
    /* Predefined polynomials. */
    /* 00 */{{POLY_7BIT_SD,  7, 0x00000000, 0x00000000, false, false}, 0xEA},
    /* 01 */{{POLY_7BIT_SD,  7, 0x0000007F, 0x00000000, false, false}, 0xA0},
    /* 02 */{{POLY_7BIT_SD,  7, 0x0000002B, 0x00000000, false, false}, 0x74},
    /* 03 */{{POLY_7BIT_SD,  7, 0x00000000, 0x0000007F, false, false}, 0x95},
    /* 04 */{{POLY_7BIT_SD,  7, 0x00000000, 0x0000002B, false, false}, 0xC1},
    /* 05 */{{POLY_7BIT_SD,  7, 0x00000000, 0x00000000, true, false}, 0xA4},
    /* 06 */{{POLY_7BIT_SD,  7, 0x00000000, 0x00000000, false, true }, 0x57},


    /* 07 */{{POLY_8BIT_CCITT,  8, 0x00000000, 0x00000000, false, false}, 0xF4},
    /* 08 */{{POLY_8BIT_CCITT,  8, 0x000000FF, 0x00000000, false, false}, 0xFB},
    /* 09 */{{POLY_8BIT_CCITT,  8, 0x000000AB, 0x00000000, false, false}, 0x87},
    /* 10 */{{POLY_8BIT_CCITT,  8, 0x00000000, 0x000000FF, false, false}, 0x0B},
    /* 11 */{{POLY_8BIT_CCITT,  8, 0x00000000, 0x000000AB, false, false}, 0x5F},
    /* 12 */{{POLY_8BIT_CCITT,  8, 0x00000000, 0x00000000, true, false}, 0x04},
    /* 13 */{{POLY_8BIT_CCITT,  8, 0x00000000, 0x00000000, false, true }, 0x2F},


    /* 14 */{{POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, false, false}, 0x31C3},
    /* 15 */{{POLY_16BIT_CCITT, 16, 0x0000FFFF, 0x00000000, false, false}, 0x29B1},
    /* 16 */{{POLY_16BIT_CCITT, 16, 0x0000ABAB, 0x00000000, false, false}, 0x7D70},
    /* 17 */{{POLY_16BIT_CCITT, 16, 0x00000000, 0x0000FFFF, false, false}, 0xCE3C},
    /* 18 */{{POLY_16BIT_CCITT, 16, 0x00000000, 0x0000ABAB, false, false}, 0x9A68},
    /* 19 */{{POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, true, false}, 0x9184},
    /* 20 */{{POLY_16BIT_CCITT, 16, 0x00000000, 0x00000000, false, true }, 0xC38C},


    /* 21 */{{POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8},
    /* 22 */{{POLY_16BIT_IBM, 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7},
    /* 23 */{{POLY_16BIT_IBM, 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887},
    /* 24 */{{POLY_16BIT_IBM, 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117},
    /* 25 */{{POLY_16BIT_IBM, 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543},
    /* 26 */{{POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, true, false}, 0xBCDD},
    /* 27 */{{POLY_16BIT_IBM, 16, 0x00000000, 0x00000000, false, true }, 0x177F},


    /* 28 */{{POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F},
    /* 29 */{{POLY_32BIT_ANSI, 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7},
    /* 30 */{{POLY_32BIT_ANSI, 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA},
    /* 31 */{{POLY_32BIT_ANSI, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680},
    /* 32 */{{POLY_32BIT_ANSI, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4},
    /* 33 */{{POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4},
    /* 34 */{{POLY_32BIT_ANSI, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591},


    /* Not-predefined polynomials. */
    /* 35 */{{POLY_8BIT_MAXIM,  8, 0x00000000, 0x00000000, false, false}, 0xA2},
    /* 36 */{{POLY_8BIT_MAXIM,  8, 0x000000FF, 0x00000000, false, false}, 0xF7},
    /* 37 */{{POLY_8BIT_MAXIM,  8, 0x000000AB, 0x00000000, false, false}, 0x71},
    /* 38 */{{POLY_8BIT_MAXIM,  8, 0x00000000, 0x000000FF, false, false}, 0x5D},
    /* 39 */{{POLY_8BIT_MAXIM,  8, 0x00000000, 0x000000AB, false, false}, 0x09},
    /* 40 */{{POLY_8BIT_MAXIM,  8, 0x00000000, 0x00000000, true, false}, 0x85},
    /* 41 */{{POLY_8BIT_MAXIM,  8, 0x00000000, 0x00000000, false, true }, 0x45},


    /* 42 */{{POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, false}, 0xFEE8},
    /* 43 */{{POLY_16BIT_MAXIM, 16, 0x0000FFFF, 0x00000000, false, false}, 0xAEE7},
    /* 44 */{{POLY_16BIT_MAXIM, 16, 0x0000ABAB, 0x00000000, false, false}, 0x0887},
    /* 45 */{{POLY_16BIT_MAXIM, 16, 0x00000000, 0x0000FFFF, false, false}, 0x0117},
    /* 46 */{{POLY_16BIT_MAXIM, 16, 0x00000000, 0x0000ABAB, false, false}, 0x5543},
    /* 47 */{{POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, true, false}, 0xBCDD},
    /* 48 */{{POLY_16BIT_MAXIM, 16, 0x00000000, 0x00000000, false, true }, 0x177F},


    /* 49 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, false}, 0x89A1897F},
    /* 50 */{{POLY_32BIT_POSIX, 32, 0xFFFFFFFF, 0x00000000, false, false}, 0x0376E6E7},
    /* 51 */{{POLY_32BIT_POSIX, 32, 0xABABABAB, 0x00000000, false, false}, 0x871A2FAA},
    /* 52 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680},
    /* 53 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4},
    /* 54 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4},
    /* 55 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591},
};

Copy link
Contributor

@jamesbeyond jamesbeyond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quickly scan through the code, mostly should be looks good.
I guess the best way to verify the test is running them :)

{
return t | a0 | a1 | a2 | a3;
}
T member_func5(T a0, T a1, T a2, T a3, T a4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These not look as neat as the old version, but if this is the coding style rules, I have no objection to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is how it is

return t | a0 | a1 | a2 | a3;
}
T member_func5(T a0, T a1, T a2, T a3, T a4)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are same

/* 52 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0xFFFFFFFF, false, false}, 0x765E7680},
/* 53 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0xABABABAB, false, false}, 0x220A22D4},
/* 54 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, true, false}, 0x11B4BFB4},
/* 55 */{{POLY_32BIT_POSIX, 32, 0x00000000, 0x00000000, false, true }, 0xFE918591},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

astyle break the alignment a bit.

Copy link
Member

@fkjagodzinski fkjagodzinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I don't have a strong preference for formatting, I do understand @mprse here. We could enclose such aligned tables in a section with different astyle format. I'm not sure if this tool provides such option though.

/* 03 */{{POLY_7BIT_SD, 7, 0x00000000, 0x0000007F, false, false}, 0x95},
/* 04 */{{POLY_7BIT_SD, 7, 0x00000000, 0x0000002B, false, false}, 0xC1},
/* 05 */{{POLY_7BIT_SD, 7, 0x00000000, 0x00000000, true, false}, 0xA4},
/* 06 */{{POLY_7BIT_SD, 7, 0x00000000, 0x00000000, false, true }, 0x57},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still redundant spaces here.

Leave as it is for readability
@0xc0170
Copy link
Contributor Author

0xc0170 commented Aug 3, 2018

IMAO readability of the original version is still better. Maybe it would be good to make some exception for such tables, since readability is here the most important. In this case it is not so bad, but if length of input values was more diverse, it would be much harder to read this.

I find readability for both the same. I reverted that manual change, and left the table as it was. It should be OK now

Copy link
Contributor

@mprse mprse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally OK. I can live with the not pretty table.

Copy link
Contributor

@mprse mprse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed the last update.
Looks good!

@0xc0170
Copy link
Contributor Author

0xc0170 commented Aug 3, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Aug 3, 2018

Build : SUCCESS

Build number : 2730
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7605/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Aug 3, 2018

@mbed-ci
Copy link

mbed-ci commented Aug 3, 2018

@cmonr
Copy link
Contributor

cmonr commented Aug 3, 2018

/morph uvisor-test

@0xc0170
Copy link
Contributor Author

0xc0170 commented Aug 6, 2018

@ARMmbed/mbed-os-maintainers Needs one of your review and should be good to go

@cmonr
Copy link
Contributor

cmonr commented Aug 6, 2018

Interesting that astyle has a method of ignoring code blocks.

@cmonr cmonr merged commit 1e676f6 into ARMmbed:master Aug 6, 2018
@0xc0170 0xc0170 removed the needs: CI label Aug 6, 2018
pan- pushed a commit to pan-/mbed that referenced this pull request Aug 22, 2018
@adbridge
Copy link
Contributor

adbridge commented Sep 7, 2018

This sits on top of changes only for 5.10, thus moving to 5.10.1

@cmonr
Copy link
Contributor

cmonr commented Sep 30, 2018

It turns out that because this was merged before rc1 was made, it's already in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants