Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-11673

Correct shell issues/mistakes in Lustre test suites

    Details

    • Rank (Obsolete):
      9223372036854775807

      Description

      Running the Lustre test suites with shellcheck (https://github.com/koalaman/shellcheck), used in CodeFactor (https://www.codefactor.io/), has brought out a few issues. We need to correct any valid issues that these utilities bring out.

      As an example, shellcheck pointed out the following issue in sanity test 405

      18918 test_405() {
      18919         [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
      18920         [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
      18921                 skip "Layout swap lock is not supported"
      

      although in not the most straight forward way

      $ shellcheck myscript
       
      Line 18918:
       test_405() {
                  ^-- SC1009: The mentioned syntax error was in this brace group.
       
      Line 18919:
               [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
               ^-- SC1073: Couldn't parse this test expression. Fix to allow more checks.
       
      Line 18920:
               [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
               ^-- SC1026: If grouping expressions inside [..], use \( ..\).
                 ^-- SC1072: Expected test to end here (don't wrap commands in []/[[]]). Fix any mentioned problems and try again.
      

      In addition, the OpenGroup, has marked the use of some functionality as obsolete and “functionality described may be removed in a future version of this volume of POSIX.1-2017. Strictly Conforming POSIX Applications and Strictly Conforming XSI Applications shall not use obsolescent features.” In particular, under the test ([) page at http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html , use of the following are marked as obsolete:

      expression1 -a  expression2
          [OB XSI] 
          True if both expression1 and expression2 are true; otherwise, false. The -a binary primary is left associative. It has a higher precedence than -o. 
      expression1 -o  expression2
          [OB XSI] 
          True if either expression1 or expression2 is true; otherwise, false. The -o binary primary is left associative. 
      

      For a better explanation, see https://github.com/koalaman/shellcheck/wiki/SC2166.

        Attachments

          Activity

            People

            • Assignee:
              jamesanunez James Nunez
              Reporter:
              jamesanunez James Nunez
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: