Skip to content

Commit f1fe687

Browse files
authored
Merge pull request #40 from aggarg/build_check
Add CI build check
2 parents b4e74b2 + 9fe6bfe commit f1fe687

File tree

10 files changed

+438
-40
lines changed

10 files changed

+438
-40
lines changed

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build Check
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
env:
8+
bashPass: \033[32;1mPASSED -
9+
bashWarn: \033[33;1mWARNING -
10+
bashFail: \033[31;1mFAILED -
11+
bashEnd: \033[0m
12+
13+
jobs:
14+
BUILD-CHECK:
15+
name: Build Check
16+
runs-on: ubuntu-latest
17+
steps:
18+
- env:
19+
stepName: Checkout Repository
20+
name: ${{ env.stepName }}
21+
uses: actions/checkout@v4
22+
23+
- env:
24+
stepName: Install Tools
25+
name: ${{ env.stepName }}
26+
shell: bash
27+
run: |
28+
# ${{ env.stepName }}
29+
echo -e "::group::${{ env.stepName }}"
30+
set +e
31+
sudo apt-get -y update
32+
sudo apt-get -y install build-essential
33+
exitStatus=$?
34+
set -e
35+
echo -e "::endgroup::"
36+
if [ $exitStatus -eq 0 ]; then
37+
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
38+
else
39+
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
40+
exit 1
41+
fi
42+
43+
- env:
44+
stepName: Build
45+
name: ${{ env.stepName }}
46+
id: build-test
47+
shell: bash
48+
working-directory: test/posix_build_test
49+
run: |
50+
# ${{ env.stepName }}
51+
echo -e "::group::${{ env.stepName }}"
52+
set +e
53+
cmake -S . -B build
54+
make -C build -j
55+
exitStatus=$?
56+
set -e
57+
echo -e "::endgroup::"
58+
if [ $exitStatus -eq 0 ]; then
59+
echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}"
60+
else
61+
echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}"
62+
exit 1
63+
fi

FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_clock.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ int clock_settime( clockid_t clock_id,
202202

203203
/* This function is currently unsupported. It will always return -1 and
204204
* set errno to EPERM. */
205-
errno = EPERM;
205+
#if ( configUSE_POSIX_ERRNO == 1 )
206+
{
207+
errno = EPERM;
208+
}
209+
#endif
206210

207211
return -1;
208212
}
@@ -221,7 +225,11 @@ int nanosleep( const struct timespec * rqtp,
221225
/* Check rqtp. */
222226
if( UTILS_ValidateTimespec( rqtp ) == false )
223227
{
224-
errno = EINVAL;
228+
#if ( configUSE_POSIX_ERRNO == 1 )
229+
{
230+
errno = EINVAL;
231+
}
232+
#endif
225233
iStatus = -1;
226234
}
227235

FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_mqueue.c

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,11 @@ int mq_close( mqd_t mqdes )
440440
else
441441
{
442442
/* Queue not found; bad descriptor. */
443-
errno = EBADF;
443+
#if ( configUSE_POSIX_ERRNO == 1 )
444+
{
445+
errno = EBADF;
446+
}
447+
#endif
444448
iStatus = -1;
445449
}
446450

@@ -479,7 +483,11 @@ int mq_getattr( mqd_t mqdes,
479483
else
480484
{
481485
/* Queue not found; bad descriptor. */
482-
errno = EBADF;
486+
#if ( configUSE_POSIX_ERRNO == 1 )
487+
{
488+
errno = EBADF;
489+
}
490+
#endif
483491
iStatus = -1;
484492
}
485493

@@ -518,7 +526,11 @@ mqd_t mq_open( const char * name,
518526
if( prvValidateQueueName( name, &xNameLength ) == pdFALSE )
519527
{
520528
/* Invalid name. */
521-
errno = EINVAL;
529+
#if ( configUSE_POSIX_ERRNO == 1 )
530+
{
531+
errno = EINVAL;
532+
}
533+
#endif
522534
xMessageQueue = ( mqd_t ) -1;
523535
}
524536

@@ -528,7 +540,11 @@ mqd_t mq_open( const char * name,
528540
if( ( oflag & O_CREAT ) && ( attr != NULL ) && ( ( attr->mq_maxmsg <= 0 ) || ( attr->mq_msgsize <= 0 ) ) )
529541
{
530542
/* Invalid mq_attr.mq_maxmsg or mq_attr.mq_msgsize. */
531-
errno = EINVAL;
543+
#if ( configUSE_POSIX_ERRNO == 1 )
544+
{
545+
errno = EINVAL;
546+
}
547+
#endif
532548
xMessageQueue = ( mqd_t ) -1;
533549
}
534550
}
@@ -548,7 +564,11 @@ mqd_t mq_open( const char * name,
548564
* O_CREAT and O_EXCL. */
549565
if( ( oflag & O_EXCL ) && ( oflag & O_CREAT ) )
550566
{
551-
errno = EEXIST;
567+
#if ( configUSE_POSIX_ERRNO == 1 )
568+
{
569+
errno = EEXIST;
570+
}
571+
#endif
552572
xMessageQueue = ( mqd_t ) -1;
553573
}
554574
else
@@ -557,7 +577,11 @@ mqd_t mq_open( const char * name,
557577
if( ( ( QueueListElement_t * ) xMessageQueue )->xPendingUnlink == pdTRUE )
558578
{
559579
/* Queue pending deletion. Don't allow it to be re-opened. */
560-
errno = EINVAL;
580+
#if ( configUSE_POSIX_ERRNO == 1 )
581+
{
582+
errno = EINVAL;
583+
}
584+
#endif
561585
xMessageQueue = ( mqd_t ) -1;
562586
}
563587
else
@@ -588,13 +612,21 @@ mqd_t mq_open( const char * name,
588612
name,
589613
xNameLength ) == pdFALSE )
590614
{
591-
errno = ENOSPC;
615+
#if ( configUSE_POSIX_ERRNO == 1 )
616+
{
617+
errno = ENOSPC;
618+
}
619+
#endif
592620
xMessageQueue = ( mqd_t ) -1;
593621
}
594622
}
595623
else
596624
{
597-
errno = ENOENT;
625+
#if ( configUSE_POSIX_ERRNO == 1 )
626+
{
627+
errno = ENOENT;
628+
}
629+
#endif
598630
xMessageQueue = ( mqd_t ) -1;
599631
}
600632
}
@@ -651,7 +683,11 @@ ssize_t mq_timedreceive( mqd_t mqdes,
651683
if( prvFindQueueInList( NULL, NULL, mqdes ) == pdFALSE )
652684
{
653685
/* Queue not found; bad descriptor. */
654-
errno = EBADF;
686+
#if ( configUSE_POSIX_ERRNO == 1 )
687+
{
688+
errno = EBADF;
689+
}
690+
#endif
655691
xStatus = -1;
656692
}
657693

@@ -661,7 +697,11 @@ ssize_t mq_timedreceive( mqd_t mqdes,
661697
if( msg_len < ( size_t ) pxMessageQueue->xAttr.mq_msgsize )
662698
{
663699
/* msg_len too small. */
664-
errno = EMSGSIZE;
700+
#if ( configUSE_POSIX_ERRNO == 1 )
701+
{
702+
errno = EMSGSIZE;
703+
}
704+
#endif
665705
xStatus = -1;
666706
}
667707
}
@@ -675,7 +715,11 @@ ssize_t mq_timedreceive( mqd_t mqdes,
675715

676716
if( iCalculateTimeoutReturn != 0 )
677717
{
678-
errno = iCalculateTimeoutReturn;
718+
#if ( configUSE_POSIX_ERRNO == 1 )
719+
{
720+
errno = iCalculateTimeoutReturn;
721+
}
722+
#endif
679723
xStatus = -1;
680724
}
681725
}
@@ -694,12 +738,20 @@ ssize_t mq_timedreceive( mqd_t mqdes,
694738
if( pxMessageQueue->xAttr.mq_flags & O_NONBLOCK )
695739
{
696740
/* Set errno to EAGAIN for nonblocking mq. */
697-
errno = EAGAIN;
741+
#if ( configUSE_POSIX_ERRNO == 1 )
742+
{
743+
errno = EAGAIN;
744+
}
745+
#endif
698746
}
699747
else
700748
{
701749
/* Otherwise, set errno to ETIMEDOUT. */
702-
errno = ETIMEDOUT;
750+
#if ( configUSE_POSIX_ERRNO == 1 )
751+
{
752+
errno = ETIMEDOUT;
753+
}
754+
#endif
703755
}
704756

705757
xStatus = -1;
@@ -743,7 +795,11 @@ int mq_timedsend( mqd_t mqdes,
743795
if( prvFindQueueInList( NULL, NULL, mqdes ) == pdFALSE )
744796
{
745797
/* Queue not found; bad descriptor. */
746-
errno = EBADF;
798+
#if ( configUSE_POSIX_ERRNO == 1 )
799+
{
800+
errno = EBADF;
801+
}
802+
#endif
747803
iStatus = -1;
748804
}
749805

@@ -753,7 +809,11 @@ int mq_timedsend( mqd_t mqdes,
753809
if( msg_len > ( size_t ) pxMessageQueue->xAttr.mq_msgsize )
754810
{
755811
/* msg_len too large. */
756-
errno = EMSGSIZE;
812+
#if ( configUSE_POSIX_ERRNO == 1 )
813+
{
814+
errno = EMSGSIZE;
815+
}
816+
#endif
757817
iStatus = -1;
758818
}
759819
}
@@ -767,7 +827,11 @@ int mq_timedsend( mqd_t mqdes,
767827

768828
if( iCalculateTimeoutReturn != 0 )
769829
{
770-
errno = iCalculateTimeoutReturn;
830+
#if ( configUSE_POSIX_ERRNO == 1 )
831+
{
832+
errno = iCalculateTimeoutReturn;
833+
}
834+
#endif
771835
iStatus = -1;
772836
}
773837
}
@@ -785,7 +849,11 @@ int mq_timedsend( mqd_t mqdes,
785849
if( xSendData.pcData == NULL )
786850
{
787851
/* msg_len too large. */
788-
errno = EMSGSIZE;
852+
#if ( configUSE_POSIX_ERRNO == 1 )
853+
{
854+
errno = EMSGSIZE;
855+
}
856+
#endif
789857
iStatus = -1;
790858
}
791859
else
@@ -806,12 +874,20 @@ int mq_timedsend( mqd_t mqdes,
806874
if( pxMessageQueue->xAttr.mq_flags & O_NONBLOCK )
807875
{
808876
/* Set errno to EAGAIN for nonblocking mq. */
809-
errno = EAGAIN;
877+
#if ( configUSE_POSIX_ERRNO == 1 )
878+
{
879+
errno = EAGAIN;
880+
}
881+
#endif
810882
}
811883
else
812884
{
813885
/* Otherwise, set errno to ETIMEDOUT. */
814-
errno = ETIMEDOUT;
886+
#if ( configUSE_POSIX_ERRNO == 1 )
887+
{
888+
errno = ETIMEDOUT;
889+
}
890+
#endif
815891
}
816892

817893
/* Free the allocated queue data. */
@@ -840,7 +916,11 @@ int mq_unlink( const char * name )
840916
if( prvValidateQueueName( name, &xNameSize ) == pdFALSE )
841917
{
842918
/* Error with mq name. */
843-
errno = EINVAL;
919+
#if ( configUSE_POSIX_ERRNO == 1 )
920+
{
921+
errno = EINVAL;
922+
}
923+
#endif
844924
iStatus = -1;
845925
}
846926

@@ -873,7 +953,11 @@ int mq_unlink( const char * name )
873953
else
874954
{
875955
/* The named message queue doesn't exist. */
876-
errno = ENOENT;
956+
#if ( configUSE_POSIX_ERRNO == 1 )
957+
{
958+
errno = ENOENT;
959+
}
960+
#endif
877961
iStatus = -1;
878962
}
879963

0 commit comments

Comments
 (0)