CI-unixish.yml: fixed and enabled all `build` steps for macos (#4832)

This commit is contained in:
Oliver Stöneberg 2023-03-02 20:54:30 +01:00 committed by GitHub
parent b53bb36798
commit 514e605598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 34 deletions

View File

@ -314,7 +314,7 @@ jobs:
if: contains(matrix.os, 'macos')
run: |
# pcre was removed from runner images in November 2022
brew install coreutils python3 pcre
brew install coreutils python3 pcre gnu-sed
- name: Install missing Python packages
run: |
@ -335,9 +335,8 @@ jobs:
run: |
make -j$(nproc) check HAVE_RULES=yes
# the script uses sed parameters not supported by MacOS
# requires "gnu-sed" installed on macos
- name: Run extra tests
if: contains(matrix.os, 'ubuntu')
run: |
tools/generate_and_run_more_tests.sh
@ -351,9 +350,8 @@ jobs:
cd 'cpp check/test/cli'
python3 -m pytest test-*.py
# fails on macos since some includes (e.g. sys/epoll.h) are not available
- name: Run cfg tests
if: contains(matrix.os, 'ubuntu') && matrix.os != 'ubuntu-22.04'
if: matrix.os != 'ubuntu-22.04'
run: |
make -j$(nproc) checkcfg
@ -364,9 +362,7 @@ jobs:
env:
STRICT: 1
# it seems macos has no "wc" command
- name: Run showtimetop5 tests
if: contains(matrix.os, 'ubuntu')
run: |
./tools/test_showtimetop5.sh

View File

@ -19,14 +19,17 @@
#include <sys/mman.h>
#include <sys/sem.h>
#include <wchar.h>
#ifndef __CYGWIN__
#if !defined(__CYGWIN__) && !(defined(__APPLE__) && defined(__MACH__))
#include <sys/epoll.h>
#endif
#include <strings.h>
#ifdef __gnu_linux__
#include <error.h>
#endif
#include <getopt.h>
#include <netdb.h>
#ifdef __gnu_linux__
void unreachableCode_error(void) // #11197
{
error(1, 0, ""); // will call exit() if the first parameter is non-zero
@ -34,6 +37,7 @@ void unreachableCode_error(void) // #11197
// TODO cppcheck-suppress unreachableCode
int i;
}
#endif
int nullPointer_gethostbyname2_r(const char* name, int af, struct hostent* ret, char* buf, size_t buflen, struct hostent** result, int* h_errnop)
{
@ -431,7 +435,7 @@ void leakReturnValNotUsed()
return;
}
#ifndef __CYGWIN__
#if !defined(__CYGWIN__) && !(defined(__APPLE__) && defined(__MACH__))
int nullPointer_epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
{
// no warning is expected

View File

@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
#define _BSD_SOURCE
#include <aio.h>
#include <stdio.h> // <- FILE
#include <dirent.h>
@ -19,7 +21,7 @@
#include <pwd.h>
#include <dlfcn.h>
#include <fcntl.h>
// unavailable on some linux systems #include <ndbm.h>
// #include <ndbm.h> // unavailable on some linux systems
#include <netdb.h>
#include <regex.h>
#include <time.h>
@ -28,20 +30,23 @@
#include <stdarg.h>
#include <ctype.h>
#include <stdbool.h>
#if !(defined(__APPLE__) && defined(__MACH__))
#include <mqueue.h>
#define _XOPEN_SOURCE
#endif
#include <stdlib.h>
#include <unistd.h>
#include <wchar.h>
#include <string.h>
#include <strings.h>
#if !(defined(__APPLE__) && defined(__MACH__))
void nullPointer_mq_timedsend(mqd_t mqdes, const char* msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec* abs_timeout) {
// cppcheck-suppress nullPointer
(void) mq_timedsend(mqdes, NULL, msg_len, msg_prio, abs_timeout);
// cppcheck-suppress nullPointer
(void) mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
}
#endif
#if __TRACE_H__ // <trace.h>
@ -143,6 +148,7 @@ int nullPointer_getopt(int argc, char* const argv[], const char* optstring)
return getopt(argc, argv, optstring);
}
#if !(defined(__APPLE__) && defined(__MACH__))
int invalidFunctionArgStr_mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
{
// No warning is expected for:
@ -150,6 +156,7 @@ int invalidFunctionArgStr_mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_l
(void) mq_send(mqdes, &msg, 1, 0);
return mq_send(mqdes, msg_ptr, msg_len, 0);
}
#endif
void invalidFunctionArgStr_mbsnrtowcs(void)
{
@ -492,6 +499,7 @@ int nullPointer_aio_suspend(const struct aiocb *const aiocb_list[], int nitems,
return aio_suspend(aiocb_list, nitems, timeout);
}
#ifdef __linux__
// Note: Since glibc 2.28, this function symbol is no longer available to newly linked applications.
void invalidFunctionArg_llseek(int fd, loff_t offset, int origin)
{
@ -522,6 +530,7 @@ void invalidFunctionArg_llseek(int fd, loff_t offset, int origin)
// cppcheck-suppress llseekCalled
(void)llseek(fd, offset, SEEK_END);
}
#endif
void invalidFunctionArg_lseek64(int fd, off_t offset, int origin)
{

View File

@ -27,9 +27,9 @@ CPPCHECK_OPT='--check-library --platform=unix64 --enable=style,information --inc
# Compiler settings
CXX=g++
CXX_OPT='-fsyntax-only -std=c++2a -Wno-format -Wno-format-security -Wno-deprecated-declarations'
CXX_OPT='-fsyntax-only -w -std=c++2a'
CC=gcc
CC_OPT='-Wno-format -Wno-stringop-overread -Wno-nonnull -Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-format-security -Wno-nonnull -fsyntax-only'
CC_OPT='-fsyntax-only -w -std=c11'
function get_pkg_config_cflags {
set +e
@ -194,7 +194,10 @@ function sqlite3_fn {
# openmp.c
function openmp_fn {
${CC} ${CC_OPT} -fopenmp ${DIR}openmp.c
# MacOS compiler has no OpenMP by default
if ! command -v sw_vers; then
${CC} ${CC_OPT} -fopenmp ${DIR}openmp.c
fi
}
# python.c

View File

@ -28,6 +28,8 @@
#endif
#include <inttypes.h>
#include <float.h>
#include <stdarg.h>
#include <sys/types.h>
size_t invalidFunctionArgStr_wcslen(void)
{

View File

@ -1,6 +1,9 @@
#!/bin/bash
# Script Used by generate_and_run_more_tests.sh
# "gsed" is a GNU compatible version of "sed" on MacOS
SED_CMD=$(command -v gsed || command -v sed)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e
@ -19,85 +22,85 @@ $CPPCHECK -q --template=cppcheck1 . 2> 1.txt
# (!x) => (x==0)
sed -ri 's/([(&][ ]*)\!([a-z]+)([ ]*[&)])/\1\2==0\3/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)\!([a-z]+)([ ]*[&)])/\1\2==0\3/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x==0) => (0==x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*==[ ]*0([ ]*[&)])/\10==\2\3/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*==[ ]*0([ ]*[&)])/\10==\2\3/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (0==x) => (!x)
sed -ri 's/([(&][ ]*)0[ ]*==[ ]*([a-z]+)([ ]*[&)])/\1!\2\3/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)0[ ]*==[ ]*([a-z]+)([ ]*[&)])/\1!\2\3/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# if (x) => (x!=0)
sed -ri 's/(if[ ]*\([ ]*[a-z]+)([ ]*[&)])/\1!=0\2/' *.cpp
$SED_CMD -ri 's/(if[ ]*\([ ]*[a-z]+)([ ]*[&)])/\1!=0\2/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# while (x) => (x!=0)
sed -ri 's/(while[ ]*\([ ]*[a-z]+)([ ]*[&)])/\1!=0\2/' *.cpp
$SED_CMD -ri 's/(while[ ]*\([ ]*[a-z]+)([ ]*[&)])/\1!=0\2/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x!=0) => (0!=x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*!=[ ]*0([ ]*[&)])/\10!=\2\3/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*!=[ ]*0([ ]*[&)])/\10!=\2\3/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (0!=x) => (x)
sed -ri 's/([(&][ ]*)0[ ]*!=[ ]*([a-z]+[ ]*[&)])/\1\2/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)0[ ]*!=[ ]*([a-z]+[ ]*[&)])/\1\2/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x < 0) => (0 > x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*<[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x <= 0) => (0 >= x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x > 0) => (0 < x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x >= 0) => (0 <= x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*<=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x == 123) => (123 == x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*==[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3==\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*==[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3==\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (x != 123) => (123 != x)
sed -ri 's/([(&][ ]*)([a-z]+)[ ]*\!=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3!=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)([a-z]+)[ ]*\!=[ ]*(\-?[0-9]+)([ ]*[&)])/\1\3!=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (0 < x) => (x > 0)
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<[ ]*([a-z]+)([ ]*[&)])/\1\3>\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<[ ]*([a-z]+)([ ]*[&)])/\1\3>\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (0 <= x) => (x >= 0)
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (0 > x) => (x < 0)
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (0 >= x) => (x <= 0)
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*<=[ ]*([a-z]+)([ ]*[&)])/\1\3>=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (123 == x) => (x == 123)
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*==[ ]*([a-z]+)([ ]*[&)])/\1\3==\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*==[ ]*([a-z]+)([ ]*[&)])/\1\3==\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt
# (123 != x) => (x <= 123)
sed -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*\!=[ ]*([a-z]+)([ ]*[&)])/\1\3!=\2\4/' *.cpp
$SED_CMD -ri 's/([(&][ ]*)(\-?[0-9]+)[ ]*\!=[ ]*([a-z]+)([ ]*[&)])/\1\3!=\2\4/' *.cpp
$CPPCHECK -q --template=cppcheck1 . 2> 2.txt && diff 1.txt 2.txt

View File

@ -1,6 +1,8 @@
#!/bin/bash
# "gwc" is a GNU compatible of "wc" on MacOS
WC_CMD=$(command -v gwc || command -v wc)
output=$(./cppcheck --showtime=top5 cli/cmdlineparser.h --language=c++ --quiet)
echo "$output"
if [[ "$(echo "$output" | wc -l)" != 7 ]] ; then
if [[ "$(echo "$output" | $WC_CMD -l)" != 7 ]] ; then
false
fi