Skip to content

Commit 0d828a5

Browse files
committed
Merge branch 'testsuitelibrary' of https://github.com/ricklon/Arduino
2 parents 9b42d2d + 5114d13 commit 0d828a5

File tree

10 files changed

+1734
-0
lines changed

10 files changed

+1734
-0
lines changed

libraries/ArduinoTestSuite/ArduinoTestSuite.cpp

+715
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//************************************************************************
2+
//************************************************************************
3+
//* Aug 31, 2010 <MLS> Started on TestArduino
4+
//************************************************************************
5+
6+
#ifndef _AVR_IO_H_
7+
#include <avr/io.h>
8+
#endif
9+
10+
#ifndef WProgram_h
11+
#include "WProgram.h"
12+
#endif
13+
#ifndef HardwareSerial_h
14+
#include "HardwareSerial.h"
15+
#endif
16+
17+
18+
#if defined(USART3_RX_vect)
19+
#define SERIAL_PORT_COUNT 4
20+
#elif defined(USART1_RX_vect)
21+
#define SERIAL_PORT_COUNT 2
22+
#else
23+
#define SERIAL_PORT_COUNT 1
24+
#endif
25+
26+
27+
void ATS_begin(char *manufName, char *testSuiteName);
28+
void ATS_end();
29+
30+
void ATS_PrintTestStatus(char *testString, boolean passed);
31+
boolean ATS_Test_DigitalPin(uint8_t digitalPinToTest);
32+
boolean ATS_Test_PWM_Pin(uint8_t digitalPinToTest);
33+
boolean ATS_Test_AnalogInput(uint8_t analogPintoTest);
34+
boolean ATS_Test_EEPROM(void);
35+
36+
short ATS_TestSerialLoopback(HardwareSerial *theSerialPort, char *serialPortName);
37+
38+
39+
int ATS_GetFreeMemory();
40+
41+
//************************************************************************
42+
//* this has to be an inline function because calling subroutines affects free memory
43+
inline void ATS_ReportMemoryUsage(int _memoryUsageAtStart)
44+
{
45+
int freeMemoryAtEnd;
46+
int lostMemory;
47+
boolean memoryOK;
48+
char memoryUsage[48];
49+
50+
freeMemoryAtEnd = ATS_GetFreeMemory();
51+
lostMemory = _memoryUsageAtStart - freeMemoryAtEnd;
52+
if (lostMemory == 0)
53+
{
54+
strcpy(memoryUsage, "Memory Usage");
55+
memoryOK = true;
56+
}
57+
else
58+
{
59+
sprintf(memoryUsage, "Memory Usage (lost %d bytes)", lostMemory);
60+
memoryOK = false;
61+
}
62+
ATS_PrintTestStatus(memoryUsage, memoryOK);
63+
}
64+
65+
66+
67+
extern unsigned long gTestStartTime;
68+
extern int gYotalErrors;
69+
extern int gTestCount;
70+
71+
72+
#define PASSED true
73+
#define FAILED false
74+
+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
//**************************************************************************************************
2+
//*
3+
//* Atmel AVR CPU name strings
4+
//*
5+
//**************************************************************************************************
6+
//* Sep 19, 2010 <MLS> Started on avr_cpunames.h
7+
//**************************************************************************************************
8+
9+
//#include "avr_cpunames.h"
10+
11+
//**************************************************************************************************
12+
13+
14+
#if defined (__AVR_AT94K__)
15+
#define _AVR_CPU_NAME_ "AT94k"
16+
#elif defined (__AVR_AT43USB320__)
17+
#elif defined (__AVR_AT43USB355__)
18+
#elif defined (__AVR_AT76C711__)
19+
#elif defined (__AVR_AT86RF401__)
20+
#elif defined (__AVR_AT90PWM1__)
21+
#elif defined (__AVR_AT90PWM2__)
22+
#elif defined (__AVR_AT90PWM2B__)
23+
#elif defined (__AVR_AT90PWM3__)
24+
#elif defined (__AVR_AT90PWM3B__)
25+
#elif defined (__AVR_AT90PWM216__)
26+
#elif defined (__AVR_AT90PWM316__)
27+
#elif defined (__AVR_ATmega32C1__)
28+
#elif defined (__AVR_ATmega32M1__)
29+
#elif defined (__AVR_ATmega32U4__)
30+
#define _AVR_CPU_NAME_ "ATmega32U4"
31+
#elif defined (__AVR_ATmega32U6__)
32+
#define _AVR_CPU_NAME_ "ATmega32U6"
33+
#elif defined (__AVR_ATmega128__)
34+
#define _AVR_CPU_NAME_ "Atmega128"
35+
#elif defined (__AVR_ATmega1280__)
36+
#define _AVR_CPU_NAME_ "ATmega1280"
37+
#elif defined (__AVR_ATmega1281__)
38+
#define _AVR_CPU_NAME_ "ATmega1281"
39+
#elif defined (__AVR_ATmega1284P__)
40+
#define _AVR_CPU_NAME_ "ATmega1284"
41+
#elif defined (__AVR_ATmega2560__)
42+
#define _AVR_CPU_NAME_ "ATmega2560"
43+
#elif defined (__AVR_ATmega2561__)
44+
#define _AVR_CPU_NAME_ "ATmega2561"
45+
#elif defined (__AVR_AT90CAN32__)
46+
#define _AVR_CPU_NAME_ "AT90CAN32"
47+
#elif defined (__AVR_AT90CAN64__)
48+
#define _AVR_CPU_NAME_ "AT90CAN64"
49+
#elif defined (__AVR_AT90CAN128__)
50+
#define _AVR_CPU_NAME_ "AT90CAN128"
51+
#elif defined (__AVR_AT90USB82__)
52+
#define _AVR_CPU_NAME_ "AT90USB82"
53+
#elif defined (__AVR_AT90USB162__)
54+
#define _AVR_CPU_NAME_ "AT90USB162"
55+
#elif defined (__AVR_AT90USB646__)
56+
#define _AVR_CPU_NAME_ "AT90USB646"
57+
#elif defined (__AVR_AT90USB647__)
58+
#define _AVR_CPU_NAME_ "AT90USB647"
59+
#elif defined (__AVR_AT90USB1286__)
60+
#define _AVR_CPU_NAME_ "AT90USB1286"
61+
#elif defined (__AVR_AT90USB1287__)
62+
#define _AVR_CPU_NAME_ "AT90USB1287"
63+
#elif defined (__AVR_ATmega64__)
64+
#define _AVR_CPU_NAME_ "ATmega64"
65+
#elif defined (__AVR_ATmega640__)
66+
#define _AVR_CPU_NAME_ "ATmega640"
67+
#elif defined (__AVR_ATmega644__)
68+
#define _AVR_CPU_NAME_ "ATmega644"
69+
#elif defined (__AVR_ATmega644P__)
70+
#define _AVR_CPU_NAME_ "ATmega644P"
71+
#elif defined (__AVR_ATmega645__)
72+
#define _AVR_CPU_NAME_ "ATmega645"
73+
#elif defined (__AVR_ATmega6450__)
74+
#define _AVR_CPU_NAME_ "ATmega6450"
75+
#elif defined (__AVR_ATmega649__)
76+
#define _AVR_CPU_NAME_ "ATmega649"
77+
#elif defined (__AVR_ATmega6490__)
78+
#define _AVR_CPU_NAME_ "ATmega6490"
79+
#elif defined (__AVR_ATmega103__)
80+
#define _AVR_CPU_NAME_ "ATmega103"
81+
#elif defined (__AVR_ATmega32__)
82+
#define _AVR_CPU_NAME_ "Atmega32"
83+
#elif defined (__AVR_ATmega323__)
84+
#define _AVR_CPU_NAME_ "ATmega323"
85+
#elif defined (__AVR_ATmega324P__)
86+
#define _AVR_CPU_NAME_ "ATmega324P"
87+
#elif defined (__AVR_ATmega325__)
88+
#define _AVR_CPU_NAME_ "ATmega325"
89+
#elif defined (__AVR_ATmega325P__)
90+
#define _AVR_CPU_NAME_ "ATmega325P"
91+
#elif defined (__AVR_ATmega3250__)
92+
#define _AVR_CPU_NAME_ "ATmega3250"
93+
#elif defined (__AVR_ATmega3250P__)
94+
#define _AVR_CPU_NAME_ "ATmega3250P"
95+
#elif defined (__AVR_ATmega328P__)
96+
#define _AVR_CPU_NAME_ "ATmega328P"
97+
#elif defined (__AVR_ATmega329__)
98+
#define _AVR_CPU_NAME_ "ATmega329"
99+
#elif defined (__AVR_ATmega329P__)
100+
#define _AVR_CPU_NAME_ "ATmega329P"
101+
#elif defined (__AVR_ATmega3290__)
102+
#define _AVR_CPU_NAME_ "ATmega3290"
103+
#elif defined (__AVR_ATmega3290P__)
104+
#define _AVR_CPU_NAME_ "ATmega3290P"
105+
#elif defined (__AVR_ATmega32HVB__)
106+
#define _AVR_CPU_NAME_ "ATmega32HVB"
107+
#elif defined (__AVR_ATmega406__)
108+
#define _AVR_CPU_NAME_ "ATmega406"
109+
#elif defined (__AVR_ATmega16__)
110+
#define _AVR_CPU_NAME_ "Atmega16"
111+
#elif defined (__AVR_ATmega161__)
112+
#define _AVR_CPU_NAME_ "ATmega161"
113+
#elif defined (__AVR_ATmega162__)
114+
#define _AVR_CPU_NAME_ "ATmega162"
115+
#elif defined (__AVR_ATmega163__)
116+
#define _AVR_CPU_NAME_ "ATmega163"
117+
#elif defined (__AVR_ATmega164P__)
118+
#define _AVR_CPU_NAME_ "ATmega164P"
119+
#elif defined (__AVR_ATmega165__)
120+
#define _AVR_CPU_NAME_ "ATmega165"
121+
#elif defined (__AVR_ATmega165P__)
122+
#define _AVR_CPU_NAME_ "ATmega165P"
123+
#elif defined (__AVR_ATmega168__)
124+
#define _AVR_CPU_NAME_ "ATmega168"
125+
#elif defined (__AVR_ATmega168P__)
126+
#define _AVR_CPU_NAME_ "ATmega168P"
127+
#elif defined (__AVR_ATmega169__)
128+
#define _AVR_CPU_NAME_ "Atmega169"
129+
#elif defined (__AVR_ATmega169P__)
130+
#define _AVR_CPU_NAME_ "ATmega169P"
131+
#elif defined (__AVR_ATmega8HVA__)
132+
#define _AVR_CPU_NAME_ "ATmega8HVA"
133+
#elif defined (__AVR_ATmega16HVA__)
134+
#define _AVR_CPU_NAME_ "ATmega16HVA"
135+
#elif defined (__AVR_ATmega8__)
136+
#define _AVR_CPU_NAME_ "ATmega8"
137+
#elif defined (__AVR_ATmega48__)
138+
#define _AVR_CPU_NAME_ "ATmega48"
139+
#elif defined (__AVR_ATmega48P__)
140+
#define _AVR_CPU_NAME_ "ATmega48P"
141+
#elif defined (__AVR_ATmega88__)
142+
#define _AVR_CPU_NAME_ "ATmega88"
143+
#elif defined (__AVR_ATmega88P__)
144+
#define _AVR_CPU_NAME_ "ATmega88P"
145+
#elif defined (__AVR_ATmega8515__)
146+
#define _AVR_CPU_NAME_ "ATmega8515"
147+
#elif defined (__AVR_ATmega8535__)
148+
#define _AVR_CPU_NAME_ "ATmega8535"
149+
#elif defined (__AVR_AT90S8535__)
150+
#elif defined (__AVR_AT90C8534__)
151+
#elif defined (__AVR_AT90S8515__)
152+
#elif defined (__AVR_AT90S4434__)
153+
#elif defined (__AVR_AT90S4433__)
154+
#elif defined (__AVR_AT90S4414__)
155+
#elif defined (__AVR_ATtiny22__)
156+
#elif defined (__AVR_ATtiny26__)
157+
#elif defined (__AVR_AT90S2343__)
158+
#elif defined (__AVR_AT90S2333__)
159+
#elif defined (__AVR_AT90S2323__)
160+
#elif defined (__AVR_AT90S2313__)
161+
#elif defined (__AVR_ATtiny2313__)
162+
#define _AVR_CPU_NAME_ "ATtiny2313"
163+
#elif defined (__AVR_ATtiny13__)
164+
#elif defined (__AVR_ATtiny13A__)
165+
#elif defined (__AVR_ATtiny25__)
166+
#elif defined (__AVR_ATtiny45__)
167+
#elif defined (__AVR_ATtiny85__)
168+
#elif defined (__AVR_ATtiny24__)
169+
#elif defined (__AVR_ATtiny44__)
170+
#elif defined (__AVR_ATtiny84__)
171+
#elif defined (__AVR_ATtiny261__)
172+
#elif defined (__AVR_ATtiny461__)
173+
#elif defined (__AVR_ATtiny861__)
174+
#elif defined (__AVR_ATtiny43U__)
175+
#elif defined (__AVR_ATtiny48__)
176+
#elif defined (__AVR_ATtiny88__)
177+
#elif defined (__AVR_ATtiny167__)
178+
179+
#else
180+
#error cpu not defined
181+
#endif
182+
183+
184+
#if !defined (_AVR_CPU_NAME_)
185+
// #define _AVR_CPU_NAME_ "UNKNOWN"
186+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//************************************************************************
2+
//* Arduino Test of Arduino Constants
3+
//* (C) 2010 by Rick Anderson
4+
//* Open source as per standard Arduino code
5+
//*
6+
//************************************************************************
7+
//* Oct 16, 2010 <ROA> Test of Arduino Constants
8+
//************************************************************************
9+
10+
#include "WProgram.h"
11+
#include "HardwareSerial.h"
12+
#include <ArduinoTestSuite.h>
13+
14+
//************************************************************************
15+
void setup()
16+
{
17+
int startMemoryUsage;
18+
19+
//Start memory usage must be site prior to ATS_begin
20+
startMemoryUsage = ATS_GetFreeMemory();
21+
ATS_begin("Arduino", "Test of Arduino Constants");
22+
/*
23+
* Test Run Start
24+
*/
25+
26+
27+
//test true constant
28+
ATS_PrintTestStatus("1. Test of true constant", true == 1);
29+
30+
//test false consts
31+
ATS_PrintTestStatus( "2. Test of false constant", false == 0);
32+
33+
//Test of HIGH == 1
34+
ATS_PrintTestStatus( "3. Test of HIGH == 1", HIGH == 1);
35+
36+
//Test of LOW == 0
37+
ATS_PrintTestStatus( "4. Test of LOW == 0", LOW == 0);
38+
39+
//Test of INPUT == 1
40+
ATS_PrintTestStatus( "5. Test of INPUT == 1", HIGH == 1);
41+
42+
//Test of OUTPUT == 0
43+
ATS_PrintTestStatus( "6. Test of OUTPUT == 0", LOW == 0);
44+
45+
//test decimal
46+
ATS_PrintTestStatus( "7. Test of decimal constant", 101 == ((1 * pow(10,2)) + (0 * pow(10,1)) + 1));
47+
48+
//test binary
49+
ATS_PrintTestStatus( "8. Test of binary constant", B101 == 5);
50+
51+
//test octal
52+
ATS_PrintTestStatus( "9. Test of octal constant", 0101 == 65);
53+
54+
//test hexadecimal
55+
ATS_PrintTestStatus( "7. Test of hexadecimal constant", (0x101 == 257));
56+
57+
/*
58+
* Test Run End
59+
*/
60+
ATS_ReportMemoryUsage(startMemoryUsage);
61+
ATS_end();
62+
63+
}
64+
65+
66+
//************************************************************************
67+
void loop()
68+
{
69+
70+
71+
}
72+
73+
74+
75+
76+

libraries/ArduinoTestSuite/examples/ATS_Delay/ATS_Delay.pde

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//************************************************************************//* Arduino Test Suite//* ATS_ToneTest//* //* Copyright (c) 2010 Mark Sproul All right reserved.//* //* This library is free software; you can redistribute it and/or//* modify it under the terms of the GNU Lesser General Public//* License as published by the Free Software Foundation; either//* version 2.1 of the License, or (at your option) any later version.//* //* This library is distributed in the hope that it will be useful,//* but WITHOUT ANY WARRANTY; without even the implied warranty of//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU//* Lesser General Public License for more details.//* //* You should have received a copy of the GNU Lesser General Public//* License along with this library; if not, write to the Free Software//* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA//************************************************************************//* Aug 31, 2010 <MLS> Started on TestArduino//* Oct 28, 2010 <MLS> Started on Delay//************************************************************************#include "WProgram.h"#include "HardwareSerial.h"#include <ArduinoTestSuite.h>//************************************************************************void setup(){short ii;short testNum;int startMemoryUsage;unsigned long startMillis;unsigned long endMillis;unsigned long deltaMillis;unsigned long errMillis;boolean passed;char testNameString[80]; startMemoryUsage = ATS_GetFreeMemory(); ATS_begin("Arduino", "DelayTest"); testNum = 1; //* we start at 2 because 0/1 are RXD/TXD for (ii=0; ii<1000; ii+= 15) { startMillis = millis(); delay(ii); endMillis = millis(); deltaMillis = endMillis - startMillis; if (deltaMillis >= ii) { errMillis = deltaMillis - ii; } else { errMillis = ii - deltaMillis; } if (errMillis <= 1) { passed = true; } else { passed = false; } sprintf(testNameString, "DelayTest.%02d (delay= %4d actual delay=%ld err=%ld)", testNum, ii, deltaMillis, errMillis); ATS_PrintTestStatus(testNameString, passed); testNum++; } ATS_ReportMemoryUsage(startMemoryUsage); ATS_end();}//************************************************************************void loop(){}

0 commit comments

Comments
 (0)