Skip to content

Commit

Permalink
[skip-changelog] Porting legacy tests to new integration-test infra…
Browse files Browse the repository at this point in the history
… (part 1...) (#2294)

* Moved out from legacy some TryBuild* integration tests

* Ported sketch_with_config integration tests out of legacy

* Ported sketch_no_functions integration tests out of legacy

* Ported sketch_with_backup_files integration tests out of legacy

* Ported sketch_with_old_lib integration tests out of legacy

* Ported sketch_with_subfolders integration tests out of legacy

* Ported sketch_with_class integration tests out of legacy

* Simplified integrationtest of preprocessor

* Ported sketch_with_typename integration tests out of legacy

* Ported sketch_with_namespace integration tests out of legacy

* Ported sketch_with_default_args integration tests out of legacy

* Ported sketch_with_inline_function_args integration tests out of legacy

* Ported sketch_with_function_signature_inside_ifdef integration tests out of legacy

* Ported sketch_with_usbcon integration tests out of legacy

* Ported sketch_with_const integration tests out of legacy

* Ported sketch_with_templates_and_shift integration tests out of legacy

* Ported sketch eol_processing integration tests out of legacy

* Ported SketchWithIfdef integration tests out of legacy

* Ported sketch_with_ifdef integration tests out of legacy

* Ported Bridge integration tests out of legacy

* Ported more Bridge integration tests out of legacy

* Ported even more Bridge integration tests out of legacy

* Better subtesting categorization

* Ported yet another Bridge integration tests out of legacy

* Ported Balanduino integration tests out of legacy

* Ported CharWithEscapedDoubleQuote integration tests out of legacy

* Ported IncludeBetweenMultilineComment integration tests out of legacy

* Ported LineContinuations integration tests out of legacy

* Ported StringWithComment integration tests out of legacy

* Ported SketchWithStruct integration tests out of legacy

* Ported SketchNoFunctionsTwoFiles integration tests out of legacy

* Ported SketchWithClassAndMethodSubstring integration tests out of legacy

* Ported SketchThatChecksIfSPIHasTransactions integration tests out of legacy

* Ported sketch_with_dependend_libraries integration tests out of legacy

* Ported sketch_with_function_pointer integration tests out of legacy

* Ported sketch_usbhost integration tests out of legacy

* Removed sketch1 from try_build* test

It's already compiled many times in other tests.

* Ported sketch9 integration tests out of legacy

* Removing no more used functions

* Ported USBHost test

* Removed no more useful test from legacy

* Removed no more needed tests
  • Loading branch information
cmaglie authored Sep 4, 2023
1 parent 3f9373a commit 0af0b44
Show file tree
Hide file tree
Showing 142 changed files with 10,627 additions and 1,363 deletions.
631 changes: 631 additions & 0 deletions internal/integrationtest/compile_4/compile_test.go

Large diffs are not rendered by default.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Arduino.h>
#line 1 {{QuoteCppString .sketch.MainFile}}
#line 1 {{QuoteCppString .sketchMainFile}}
/*
* The code is released under the GNU General Public License.
* Developed by Kristian Lauszus, TKJ Electronics 2013
Expand Down Expand Up @@ -87,11 +87,11 @@ WII Wii(&Btd); // The Wii library can communicate with Wiimotes and the Nunchuck
// This can also be done using the Android or Processing application
#endif

#line 88 {{QuoteCppString .sketch.MainFile}}
#line 88 {{QuoteCppString .sketchMainFile}}
void setup();
#line 204 {{QuoteCppString .sketch.MainFile}}
#line 204 {{QuoteCppString .sketchMainFile}}
void loop();
#line 88 {{QuoteCppString .sketch.MainFile}}
#line 88 {{QuoteCppString .sketchMainFile}}
void setup() {
/* Initialize UART */
Serial.begin(115200);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
Arduino Yún Bridge example
This example for the Arduino Yún shows how to use the
Bridge library to access the digital and analog pins
on the board through REST calls. It demonstrates how
you can create your own API when using REST style
calls through the browser.
Possible commands created in this shetch:
"/arduino/digital/13" -> digitalRead(13)
"/arduino/digital/13/1" -> digitalWrite(13, HIGH)
"/arduino/analog/2/123" -> analogWrite(2, 123)
"/arduino/analog/2" -> analogRead(2)
"/arduino/mode/13/input" -> pinMode(13, INPUT)
"/arduino/mode/13/output" -> pinMode(13, OUTPUT)
This example code is part of the public domain
http://www.arduino.cc/en/Tutorial/Bridge
*/

#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>

// Listen to the default port 5555, the Yún webserver
// will forward there all the HTTP requests you send
BridgeServer server;

void setup() {
// Bridge startup
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);

// Listen for incoming connection only from localhost
// (no one from the external network could connect)
server.listenOnLocalhost();
server.begin();
}

void loop() {
// Get clients coming from server
BridgeClient client = server.accept();

// There is a new client?
if (client) {
// Process request
process(client);

// Close connection and free resources.
client.stop();
}

delay(50); // Poll every 50ms
}

void process(BridgeClient client) {
// read the command
String command = client.readStringUntil('/');

// is "digital" command?
if (command == "digital") {
digitalCommand(client);
}

// is "analog" command?
if (command == "analog") {
analogCommand(client);
}

// is "mode" command?
if (command == "mode") {
modeCommand(client);
}
}

void digitalCommand(BridgeClient client) {
int pin, value;

// Read pin number
pin = client.parseInt();

// If the next character is a '/' it means we have an URL
// with a value like: "/digital/13/1"
if (client.read() == '/') {
value = client.parseInt();
digitalWrite(pin, value);
} else {
value = digitalRead(pin);
}

// Send feedback to client
client.print(F("Pin D"));
client.print(pin);
client.print(F(" set to "));
client.println(value);

// Update datastore key with the current pin value
String key = "D";
key += pin;
Bridge.put(key, String(value));
}

void analogCommand(BridgeClient client) {
int pin, value;

// Read pin number
pin = client.parseInt();

// If the next character is a '/' it means we have an URL
// with a value like: "/analog/5/120"
if (client.read() == '/') {
// Read value and execute command
value = client.parseInt();
analogWrite(pin, value);

// Send feedback to client
client.print(F("Pin D"));
client.print(pin);
client.print(F(" set to analog "));
client.println(value);

// Update datastore key with the current pin value
String key = "D";
key += pin;
Bridge.put(key, String(value));
} else {
// Read analog pin
value = analogRead(pin);

// Send feedback to client
client.print(F("Pin A"));
client.print(pin);
client.print(F(" reads analog "));
client.println(value);

// Update datastore key with the current pin value
String key = "A";
key += pin;
Bridge.put(key, String(value));
}
}

void modeCommand(BridgeClient client) {
int pin;

// Read pin number
pin = client.parseInt();

// If the next character is not a '/' we have a malformed URL
if (client.read() != '/') {
client.println(F("error"));
return;
}

String mode = client.readStringUntil('\r');

if (mode == "input") {
pinMode(pin, INPUT);
// Send feedback to client
client.print(F("Pin D"));
client.print(pin);
client.print(F(" configured as INPUT!"));
return;
}

if (mode == "output") {
pinMode(pin, OUTPUT);
// Send feedback to client
client.print(F("Pin D"));
client.print(pin);
client.print(F(" configured as OUTPUT!"));
return;
}

client.print(F("error: invalid mode "));
client.print(mode);
}


Loading

0 comments on commit 0af0b44

Please sign in to comment.