arduino_ci 1.4.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0b4bb5ffc81d0b5888f13b871c4b79155c5edab347d3c9211a453556690bbd2
4
- data.tar.gz: 67156a3b8c1754cb83967a60b2acb76253e06a7f676e2517dfec7e240d8a88c7
3
+ metadata.gz: a1682b05e3ac9d806fb4db22044d7f4dd463e811a4a58982c1f36c2d5d4eb0d7
4
+ data.tar.gz: f7dc2ca4881a925d645624e5141625d9e2347d82431415ddd287b133be15b694
5
5
  SHA512:
6
- metadata.gz: a31668d85a2a80b705389f9b42916decd5c73848da29ee1e42094ae8d9fb1f77ccd410450734356cb838ec50a635c0a8421afd690d0ae98de18611e71bfe0c03
7
- data.tar.gz: ec2e5655f327ecf0fac4ba62c47f4e29c113193efcf65b70f38929f4973635171bfd08f7a9351748a6162aac6a18be59de9948e6566b003c59797f4ce87635ab
6
+ metadata.gz: bc976a396fad19beb76ce802d3383c5590fe9483730cc9ff6fd521b86c5f265d25296c970766f3661ffbbdb133d4d880bbd045f43e80a23c39e3a760f2f1a81c
7
+ data.tar.gz: b97d68574158fa988677cb1c7fe9645a3365381f35750b0a5c52ba144a6b322a84861285376816939b73b2dacb6c7d76ba795cba7e6c87614f6a6efe6d547484
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # ArduinoCI Ruby gem (`arduino_ci`)
3
3
  [![Gem Version](https://badge.fury.io/rb/arduino_ci.svg)](https://rubygems.org/gems/arduino_ci)
4
- [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/1.4.0)
4
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/arduino_ci/1.6.0)
5
5
  [![Gitter](https://badges.gitter.im/Arduino-CI/arduino_ci.svg)](https://gitter.im/Arduino-CI/arduino_ci?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
6
6
  [![GitHub Marketplace](https://img.shields.io/badge/Get_it-on_Marketplace-informational.svg)](https://github.com/marketplace/actions/arduino_ci)
7
7
 
@@ -118,11 +118,11 @@ gem 'arduino_ci', path: '/path/to/development/dir/for/arduino_ci'
118
118
 
119
119
  ### Installing the Dependencies
120
120
 
121
- Fulfilling the `arduino_ci` library dependency is as easy as running either of these two commands:
121
+ Fulfilling the `arduino_ci` library dependency is as easy as running one or both of these commands:
122
122
 
123
123
  ```console
124
- $ bundle install # adds packages to global library (may require admin rights)
125
- $ bundle install --path vendor/bundle # adds packages to local library
124
+ $ bundle config set --local path 'vendor/bundle' # if you lack administrative privileges to install globally
125
+ $ bundle install
126
126
  ```
127
127
 
128
128
  This will create a `Gemfile.lock` in your project directory, which you may optionally check into source control. A broader introduction to ruby dependencies is outside the scope of this document.
@@ -169,7 +169,7 @@ jobs:
169
169
  runTest:
170
170
  runs-on: ubuntu-latest
171
171
  steps:
172
- - uses: actions/checkout@v2
172
+ - uses: actions/checkout@v3
173
173
  - uses: ruby/setup-ruby@v1
174
174
  with:
175
175
  ruby-version: 2.6
data/REFERENCE.md CHANGED
@@ -44,6 +44,11 @@ This allows a file (or glob) pattern to be executed in your tests directory, cre
44
44
  This allows a file (or glob) pattern to be executed in your tests directory, creating a blacklist of files to skip. E.g. `--testfile-reject=test_animal_*.cpp` would match `test_animal_cat.cpp` and `test_animal_dog.cpp` (skipping those) and test only `test_plant_rose.cpp`, `test_plant_daisy.cpp`, etc.
45
45
 
46
46
 
47
+ ### `--min-free-space` option
48
+
49
+ This specifies the minimum free SRAM memory for stack/heap, in bytes, that _must_ be leftover after compilation. This value applies globally -- to _all_ platforms that will be included in a test run.
50
+
51
+
47
52
  ### `CUSTOM_INIT_SCRIPT` environment variable
48
53
 
49
54
  If set, testing will execute (using `/bin/sh`) the script referred to by this variable -- relative to the current working directory (i.e. the root directory of the library). The script will _run_ in the Arduino Libraries directory (changing to the Libraries directory, running the script, and returning to the individual library root afterward). This enables use cases like the GitHub action to install custom library versions (i.e. a version of a library that is different than what the library manager would automatically install by name) prior to CI test runs.
@@ -5,6 +5,11 @@ Mock Arduino.h library.
5
5
  Where possible, variable names from the Arduino library are used to avoid conflicts
6
6
 
7
7
  */
8
+
9
+ // signal to the developer that we are in an arduino_ci mocked environment
10
+ #define ARDUINO_CI_COMPILATION_MOCKS
11
+
12
+
8
13
  // Chars and strings
9
14
 
10
15
  #include "ArduinoDefines.h"
@@ -89,8 +89,23 @@
89
89
  #define TIMER5B 17
90
90
  #define TIMER5C 18
91
91
 
92
- #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
92
+ #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__SAM3X8E__) || defined(__SAMD21G18A__)
93
+ // Verified on these platforms, see https://github.com/Arduino-CI/arduino_ci/pull/341#issuecomment-1368118880
93
94
  #define LED_BUILTIN 13
95
+
96
+ #define A0 14
97
+ #define A1 15
98
+ #define A2 16
99
+ #define A3 17
100
+ #define A4 18
101
+ #define A5 19
102
+ #define A6 20
103
+ #define A7 21
104
+ #define A8 22
105
+ #define A9 23
106
+ #define A10 24
107
+ #define A11 25
108
+
94
109
  #endif
95
110
 
96
111
  // Arduino defines this
@@ -6,6 +6,9 @@
6
6
  #include "WString.h"
7
7
  #include "PinHistory.h"
8
8
 
9
+ // signal to the developer that we are in an arduino_ci mocked environment
10
+ #define ARDUINO_CI_GODMODE
11
+
9
12
  // random
10
13
  void randomSeed(unsigned long seed);
11
14
  long random(long vmax);
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+
3
+ #define _VECTOR(N) __vector_ ## N
4
+ #define SIGNAL ( vector )
5
+
6
+ void cli() {};
7
+ void sei() {};
@@ -0,0 +1,313 @@
1
+ /* Copyright (c) 2007 Dean Camera
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in
12
+ the documentation and/or other materials provided with the
13
+ distribution.
14
+
15
+ * Neither the name of the copyright holders nor the names of
16
+ contributors may be used to endorse or promote products derived
17
+ from this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ /* $Id$ */
33
+
34
+ #ifndef _UTIL_ATOMIC_H_
35
+ #define _UTIL_ATOMIC_H_ 1
36
+
37
+ #include <avr/io.h>
38
+ // Not required
39
+ //#include <avr/interrupt.h>
40
+
41
+ #if !defined(__DOXYGEN__)
42
+ /* Internal helper functions. */
43
+ static __inline__ uint8_t __iSeiRetVal(void)
44
+ {
45
+ // Just do nothing
46
+ //sei();
47
+ return 1;
48
+ }
49
+
50
+ static __inline__ uint8_t __iCliRetVal(void)
51
+ {
52
+ // Just do nothing
53
+ // cli();
54
+ return 1;
55
+ }
56
+
57
+ static __inline__ void __iSeiParam(const uint8_t *__s)
58
+ {
59
+ // Just do nothing
60
+ // sei();
61
+ __asm__ volatile ("" ::: "memory");
62
+ (void)__s;
63
+ }
64
+
65
+ static __inline__ void __iCliParam(const uint8_t *__s)
66
+ {
67
+ // Just do nothing
68
+ // cli();
69
+ __asm__ volatile ("" ::: "memory");
70
+ (void)__s;
71
+ }
72
+
73
+ static __inline__ void __iRestore(const uint8_t *__s)
74
+ {
75
+ SREG = *__s;
76
+ __asm__ volatile ("" ::: "memory");
77
+ }
78
+ #endif /* !__DOXYGEN__ */
79
+
80
+ /** \file */
81
+ /** \defgroup util_atomic <util/atomic.h> Atomically and Non-Atomically Executed Code Blocks
82
+
83
+ \code
84
+ #include <util/atomic.h>
85
+ \endcode
86
+
87
+ \note The macros in this header file require the ISO/IEC 9899:1999
88
+ ("ISO C99") feature of for loop variables that are declared inside
89
+ the for loop itself. For that reason, this header file can only
90
+ be used if the standard level of the compiler (option --std=) is
91
+ set to either \c c99 or \c gnu99.
92
+
93
+ The macros in this header file deal with code blocks that are
94
+ guaranteed to be executed Atomically or Non-Atmomically. The term
95
+ "Atomic" in this context refers to the unability of the respective
96
+ code to be interrupted.
97
+
98
+ These macros operate via automatic manipulation of the Global
99
+ Interrupt Status (I) bit of the SREG register. Exit paths from
100
+ both block types are all managed automatically without the need
101
+ for special considerations, i. e. the interrupt status will be
102
+ restored to the same value it has been when entering the
103
+ respective block.
104
+
105
+ A typical example that requires atomic access is a 16 (or more)
106
+ bit variable that is shared between the main execution path and an
107
+ ISR. While declaring such a variable as volatile ensures that the
108
+ compiler will not optimize accesses to it away, it does not
109
+ guarantee atomic access to it. Assuming the following example:
110
+
111
+ \code
112
+ #include <inttypes.h>
113
+ #include <avr/interrupt.h>
114
+ #include <avr/io.h>
115
+
116
+ volatile uint16_t ctr;
117
+
118
+ ISR(TIMER1_OVF_vect)
119
+ {
120
+ ctr--;
121
+ }
122
+
123
+ ...
124
+ int
125
+ main(void)
126
+ {
127
+ ...
128
+ ctr = 0x200;
129
+ start_timer();
130
+ while (ctr != 0)
131
+ // wait
132
+ ;
133
+ ...
134
+ }
135
+ \endcode
136
+
137
+ There is a chance where the main context will exit its wait loop
138
+ when the variable \c ctr just reached the value 0xFF. This happens
139
+ because the compiler cannot natively access a 16-bit variable
140
+ atomically in an 8-bit CPU. So the variable is for example at
141
+ 0x100, the compiler then tests the low byte for 0, which succeeds.
142
+ It then proceeds to test the high byte, but that moment the ISR
143
+ triggers, and the main context is interrupted. The ISR will
144
+ decrement the variable from 0x100 to 0xFF, and the main context
145
+ proceeds. It now tests the high byte of the variable which is
146
+ (now) also 0, so it concludes the variable has reached 0, and
147
+ terminates the loop.
148
+
149
+ Using the macros from this header file, the above code can be
150
+ rewritten like:
151
+
152
+ \code
153
+ #include <inttypes.h>
154
+ #include <avr/interrupt.h>
155
+ #include <avr/io.h>
156
+ #include <util/atomic.h>
157
+
158
+ volatile uint16_t ctr;
159
+
160
+ ISR(TIMER1_OVF_vect)
161
+ {
162
+ ctr--;
163
+ }
164
+
165
+ ...
166
+ int
167
+ main(void)
168
+ {
169
+ ...
170
+ ctr = 0x200;
171
+ start_timer();
172
+ sei();
173
+ uint16_t ctr_copy;
174
+ do
175
+ {
176
+ ATOMIC_BLOCK(ATOMIC_FORCEON)
177
+ {
178
+ ctr_copy = ctr;
179
+ }
180
+ }
181
+ while (ctr_copy != 0);
182
+ ...
183
+ }
184
+ \endcode
185
+
186
+ This will install the appropriate interrupt protection before
187
+ accessing variable \c ctr, so it is guaranteed to be consistently
188
+ tested. If the global interrupt state were uncertain before
189
+ entering the ATOMIC_BLOCK, it should be executed with the
190
+ parameter ATOMIC_RESTORESTATE rather than ATOMIC_FORCEON.
191
+
192
+ See \ref optim_code_reorder for things to be taken into account
193
+ with respect to compiler optimizations.
194
+ */
195
+
196
+ /** \def ATOMIC_BLOCK(type)
197
+ \ingroup util_atomic
198
+
199
+ Creates a block of code that is guaranteed to be executed
200
+ atomically. Upon entering the block the Global Interrupt Status
201
+ flag in SREG is disabled, and re-enabled upon exiting the block
202
+ from any exit path.
203
+
204
+ Two possible macro parameters are permitted, ATOMIC_RESTORESTATE
205
+ and ATOMIC_FORCEON.
206
+ */
207
+ #if defined(__DOXYGEN__)
208
+ #define ATOMIC_BLOCK(type)
209
+ #else
210
+ #define ATOMIC_BLOCK(type) for ( type, __ToDo = __iCliRetVal(); \
211
+ __ToDo ; __ToDo = 0 )
212
+ #endif /* __DOXYGEN__ */
213
+
214
+ /** \def NONATOMIC_BLOCK(type)
215
+ \ingroup util_atomic
216
+
217
+ Creates a block of code that is executed non-atomically. Upon
218
+ entering the block the Global Interrupt Status flag in SREG is
219
+ enabled, and disabled upon exiting the block from any exit
220
+ path. This is useful when nested inside ATOMIC_BLOCK sections,
221
+ allowing for non-atomic execution of small blocks of code while
222
+ maintaining the atomic access of the other sections of the parent
223
+ ATOMIC_BLOCK.
224
+
225
+ Two possible macro parameters are permitted,
226
+ NONATOMIC_RESTORESTATE and NONATOMIC_FORCEOFF.
227
+ */
228
+ #if defined(__DOXYGEN__)
229
+ #define NONATOMIC_BLOCK(type)
230
+ #else
231
+ #define NONATOMIC_BLOCK(type) for ( type, __ToDo = __iSeiRetVal(); \
232
+ __ToDo ; __ToDo = 0 )
233
+ #endif /* __DOXYGEN__ */
234
+
235
+ /** \def ATOMIC_RESTORESTATE
236
+ \ingroup util_atomic
237
+
238
+ This is a possible parameter for ATOMIC_BLOCK. When used, it will
239
+ cause the ATOMIC_BLOCK to restore the previous state of the SREG
240
+ register, saved before the Global Interrupt Status flag bit was
241
+ disabled. The net effect of this is to make the ATOMIC_BLOCK's
242
+ contents guaranteed atomic, without changing the state of the
243
+ Global Interrupt Status flag when execution of the block
244
+ completes.
245
+ */
246
+ #if defined(__DOXYGEN__)
247
+ #define ATOMIC_RESTORESTATE
248
+ #else
249
+ #define ATOMIC_RESTORESTATE uint8_t sreg_save \
250
+ __attribute__((__cleanup__(__iRestore))) = SREG
251
+ #endif /* __DOXYGEN__ */
252
+
253
+ /** \def ATOMIC_FORCEON
254
+ \ingroup util_atomic
255
+
256
+ This is a possible parameter for ATOMIC_BLOCK. When used, it will
257
+ cause the ATOMIC_BLOCK to force the state of the SREG register on
258
+ exit, enabling the Global Interrupt Status flag bit. This saves on
259
+ flash space as the previous value of the SREG register does not
260
+ need to be saved at the start of the block.
261
+
262
+ Care should be taken that ATOMIC_FORCEON is only used when it is
263
+ known that interrupts are enabled before the block's execution or
264
+ when the side effects of enabling global interrupts at the block's
265
+ completion are known and understood.
266
+ */
267
+ #if defined(__DOXYGEN__)
268
+ #define ATOMIC_FORCEON
269
+ #else
270
+ #define ATOMIC_FORCEON uint8_t sreg_save \
271
+ __attribute__((__cleanup__(__iSeiParam))) = 0
272
+ #endif /* __DOXYGEN__ */
273
+
274
+ /** \def NONATOMIC_RESTORESTATE
275
+ \ingroup util_atomic
276
+
277
+ This is a possible parameter for NONATOMIC_BLOCK. When used, it
278
+ will cause the NONATOMIC_BLOCK to restore the previous state of
279
+ the SREG register, saved before the Global Interrupt Status flag
280
+ bit was enabled. The net effect of this is to make the
281
+ NONATOMIC_BLOCK's contents guaranteed non-atomic, without changing
282
+ the state of the Global Interrupt Status flag when execution of
283
+ the block completes.
284
+ */
285
+ #if defined(__DOXYGEN__)
286
+ #define NONATOMIC_RESTORESTATE
287
+ #else
288
+ #define NONATOMIC_RESTORESTATE uint8_t sreg_save \
289
+ __attribute__((__cleanup__(__iRestore))) = SREG
290
+ #endif /* __DOXYGEN__ */
291
+
292
+ /** \def NONATOMIC_FORCEOFF
293
+ \ingroup util_atomic
294
+
295
+ This is a possible parameter for NONATOMIC_BLOCK. When used, it
296
+ will cause the NONATOMIC_BLOCK to force the state of the SREG
297
+ register on exit, disabling the Global Interrupt Status flag
298
+ bit. This saves on flash space as the previous value of the SREG
299
+ register does not need to be saved at the start of the block.
300
+
301
+ Care should be taken that NONATOMIC_FORCEOFF is only used when it
302
+ is known that interrupts are disabled before the block's execution
303
+ or when the side effects of disabling global interrupts at the
304
+ block's completion are known and understood.
305
+ */
306
+ #if defined(__DOXYGEN__)
307
+ #define NONATOMIC_FORCEOFF
308
+ #else
309
+ #define NONATOMIC_FORCEOFF uint8_t sreg_save \
310
+ __attribute__((__cleanup__(__iCliParam))) = 0
311
+ #endif /* __DOXYGEN__ */
312
+
313
+ #endif