initial buildroot for linux 5.15

This commit is contained in:
Huan.Feng
2021-12-06 14:12:13 +08:00
parent d7767d594e
commit 7b6fc358fa
12736 changed files with 508822 additions and 0 deletions
@@ -0,0 +1,2 @@
source "$BR2_EXTERNAL_OPENJDK_PATH/package/openjdk-hello-world/Config.in"
source "$BR2_EXTERNAL_OPENJDK_PATH/package/openjdk-jni-test/Config.in"
@@ -0,0 +1 @@
name: OPENJDK
@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_OPENJDK_PATH)/package/*/*.mk))
@@ -0,0 +1,5 @@
config BR2_PACKAGE_OPENJDK_HELLO_WORLD
bool "openjdk hello world"
depends on BR2_PACKAGE_OPENJDK
help
Simple class for testing openjdk
@@ -0,0 +1,7 @@
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World");
}
}
@@ -0,0 +1,18 @@
################################################################################
#
# openjdk hello world
#
################################################################################
OPENJDK_HELLO_WORLD_DEPENDENCIES = openjdk
define OPENJDK_HELLO_WORLD_BUILD_CMDS
$(INSTALL) -D $(OPENJDK_HELLO_WORLD_PKGDIR)/HelloWorld.java $(@D)/HelloWorld.java
$(JAVAC) $(@D)/HelloWorld.java
endef
define OPENJDK_HELLO_WORLD_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 755 $(@D)/HelloWorld.class $(TARGET_DIR)/usr/bin/HelloWorld.class
endef
$(eval $(generic-package))
@@ -0,0 +1,5 @@
config BR2_PACKAGE_OPENJDK_JNI_TEST
bool "openjdk JNI test"
depends on BR2_PACKAGE_OPENJDK
help
Tests openjdk JNI support
@@ -0,0 +1,9 @@
public class JniHelper
{
public void HelloManagedWorld()
{
stringMember = "Hello, Managed World";
}
public String stringMember = "Set from Java";
}
@@ -0,0 +1,92 @@
public class JniTest
{
private static void Test(
String name,
Object actual,
Object expected,
String actualAsString,
String expectedAsString)
{
if (!actual.equals(expected))
{
System.out.println(String.format(
"Test: %s failed\nExpected: \"%s\", Actual: \"%s\"",
name,
expected,
actual));
JniTest.exitCode = -1;
}
else
{
System.out.println(String.format("Test: %s passed", name));
}
}
private static void Test(
String name,
String actual,
String expected)
{
JniTest.Test(name, actual, expected, actual, expected);
}
public static void main(String[] args)
{
var actualVersion = JniWrapper.get_jni_version();
var expectedVersion = 0x000A0000;
JniTest.Test(
"Get JNI Version",
actualVersion,
expectedVersion,
String.format("0x%08X", actualVersion),
String.format("0x%08X", expectedVersion));
JniTest.Test(
"Read Native String Constant",
JniWrapper.read_constant_string(),
"Hello from C");
JniTest.Test(
"Write Java String to Native Library",
JniWrapper.write_string("Hello from Java"),
"Hello from Java");
JniTest.Test(
"Write Java Char Array to Native Library",
JniWrapper.write_char_array("Hello from Java".toCharArray()),
"Hello from Java");
var helper = new JniHelper();
JniTest.Test(
"Write String Member to Native Library",
JniWrapper.write_string_member(helper),
"Set from Java");
JniWrapper.set_string_member(helper);
JniTest.Test(
"Set String Member from Native Library",
helper.stringMember,
"Set from C");
JniWrapper.execute_java_function(helper);
JniTest.Test(
"Execeute Java Function from Native Library",
helper.stringMember,
"Hello, Managed World");
helper = JniWrapper.instantiate_java_class();
JniTest.Test(
"Instantiate Java Class",
helper.stringMember,
"Instantiated from C");
JniTest.Test(
"Call Native Library to Set System Time",
JniWrapper.set_and_write_time_in_seconds(1000),
"1000");
System.exit(exitCode);
}
public static int exitCode = 0;
}
@@ -0,0 +1,50 @@
#include "JniWrapper.h"
#include "jni_helper.h"
// Proxies the generated function calls to the jni_helper
JNIEXPORT jint JNICALL Java_JniWrapper_get_1jni_1version
(JNIEnv* env, jclass class)
{
return get_jni_version(env);
}
JNIEXPORT jstring JNICALL Java_JniWrapper_read_1constant_1string
(JNIEnv* env, jclass class)
{
return read_constant_jstring(env);
}
JNIEXPORT jstring JNICALL Java_JniWrapper_write_1string
(JNIEnv* env, jclass class, jstring string)
{
return write_jstring(env, string);
}
JNIEXPORT jstring JNICALL Java_JniWrapper_write_1char_1array
(JNIEnv* env, jclass class, jcharArray chars)
{
return write_jchar_array(env, chars);
}
JNIEXPORT jstring JNICALL Java_JniWrapper_write_1string_1member
(JNIEnv* env, jclass class, jobject helper)
{
return write_string_member(env, helper);
}
JNIEXPORT void JNICALL Java_JniWrapper_set_1string_1member
(JNIEnv* env, jclass class, jobject helper)
{
set_string_member(env, helper);
}
JNIEXPORT void JNICALL Java_JniWrapper_execute_1java_1function
(JNIEnv* env, jclass class, jobject helper)
{
execute_java_function(env, helper);
}
JNIEXPORT jobject JNICALL Java_JniWrapper_instantiate_1java_1class
(JNIEnv* env, jclass class)
{
return instantiate_java_class(env);
}
JNIEXPORT jstring JNICALL Java_JniWrapper_set_1and_1write_1time_1in_1seconds
(JNIEnv* env, jclass class, jint seconds)
{
return set_and_write_time_in_seconds(env, seconds);
}
@@ -0,0 +1,17 @@
public class JniWrapper
{
static
{
System.loadLibrary("jni_native");
}
public static native int get_jni_version();
public static native String read_constant_string();
public static native String write_string(String string);
public static native String write_char_array(char[] string);
public static native String write_string_member(JniHelper helper);
public static native void set_string_member(JniHelper helper);
public static native void execute_java_function(JniHelper helper);
public static native JniHelper instantiate_java_class();
public static native String set_and_write_time_in_seconds(int seconds);
}
@@ -0,0 +1,94 @@
#include "jni_helper.h"
#include "native.h"
// Handles Java/C interop
jint get_jni_version(JNIEnv* env)
{
return (*env)->GetVersion(env);
}
jstring read_constant_jstring(JNIEnv* env)
{
return (*env)->NewStringUTF(env, read_constant_string());
}
static jstring read_internal_string_as_jstring(JNIEnv* env)
{
return (*env)->NewStringUTF(env, read_internal_string());
}
jstring write_jstring(JNIEnv* env, jstring string)
{
const char* utf8_string = (*env)->GetStringUTFChars(env, string, NULL);
write_internal_string(utf8_string);
(*env)->ReleaseStringUTFChars(env, string, utf8_string);
return read_internal_string_as_jstring(env);
}
jstring write_jchar_array(JNIEnv* env, jcharArray chars)
{
jsize length = (*env)->GetArrayLength(env, chars);
jchar* body = (*env)->GetCharArrayElements(env, chars, NULL);
jstring input = (*env)->NewString(env, body, length);
jstring output = write_jstring(env, input);
(*env)->ReleaseCharArrayElements(env, chars, body, JNI_ABORT);
return output;
}
static jfieldID get_string_member_field(JNIEnv* env, jobject helper)
{
jclass class = (*env)->GetObjectClass(env, helper);
return (*env)->GetFieldID(env, class, "stringMember", "Ljava/lang/String;");
}
jstring write_string_member(JNIEnv* env, jobject helper)
{
jfieldID fieldID = get_string_member_field(env, helper);
jstring string = (*env)->GetObjectField(env, helper, fieldID);
return write_jstring(env, string);
}
static void set_string_member_helper(JNIEnv* env, jobject helper, const char* utf8_string)
{
jfieldID fieldID = get_string_member_field(env, helper);
jstring string = (*env)->NewStringUTF(env, utf8_string);
(*env)->SetObjectField(env, helper, fieldID, string);
}
void set_string_member(JNIEnv* env, jobject helper)
{
char stringBuffer[256];
write_external_string(stringBuffer, 256);
set_string_member_helper(env, helper, stringBuffer);
}
typedef struct
{
JNIEnv* env;
jobject object;
jmethodID methodID;
} method_parameters;
static void call_void_java_method(void* context)
{
method_parameters* parameters = (method_parameters*)context;
(*parameters->env)->CallVoidMethod(parameters->env, parameters->object, parameters->methodID);
}
void execute_java_function(JNIEnv* env, jobject helper)
{
jclass class = (*env)->GetObjectClass(env, helper);
jmethodID methodID = (*env)->GetMethodID(env, class, "HelloManagedWorld", "()V");
method_parameters parameters = {env, helper, methodID};
execute_function(call_void_java_method, (void*)&parameters);
}
jobject instantiate_java_class(JNIEnv* env)
{
jclass class = (*env)->FindClass(env, "JniHelper");
jmethodID methodID = (*env)->GetMethodID(env, class, "<init>", "()V");
jobject object =(*env)->NewObject(env, class, methodID);
set_string_member_helper(env, object, "Instantiated from C");
return object;
}
jstring set_and_write_time_in_seconds(JNIEnv* env, jint seconds)
{
set_time_in_seconds((int)seconds);
write_internal_time_in_seconds();
return read_internal_string_as_jstring(env);
}
@@ -0,0 +1,13 @@
#pragma once
#include <jni.h>
jint get_jni_version(JNIEnv* env);
jstring read_constant_jstring(JNIEnv* env);
jstring write_jstring(JNIEnv* env, jstring string);
jstring write_jchar_array(JNIEnv* env, jcharArray chars);
jstring write_string_member(JNIEnv* env, jobject helper);
void set_string_member(JNIEnv* env, jobject helper);
void execute_java_function(JNIEnv* env, jobject helper);
jobject instantiate_java_class(JNIEnv* env);
jstring set_and_write_time_in_seconds(JNIEnv* env, jint seconds);
@@ -0,0 +1,39 @@
#include "native.h"
#include <stdio.h>
#include <time.h>
// Pure native functions
#define CHAR_BUFFER_SIZE 256
static char buffer[CHAR_BUFFER_SIZE];
const char* read_constant_string()
{
return "Hello from C";
}
const char* read_internal_string()
{
return buffer;
}
void write_internal_string(const char* string)
{
snprintf(buffer, CHAR_BUFFER_SIZE, "%s", string);
}
void write_external_string(char* string, size_t maxLength)
{
snprintf(string, maxLength, "Set from C");
}
void execute_function(void(*function)(void*), void* context)
{
function(context);
}
void set_time_in_seconds(int seconds)
{
time_t timeToSet = seconds;
stime(&timeToSet);
}
void write_internal_time_in_seconds()
{
time_t systemTime = time(NULL);
snprintf(buffer, CHAR_BUFFER_SIZE, "%u", systemTime);
}
@@ -0,0 +1,11 @@
#pragma once
#include <stddef.h>
const char* read_constant_string();
const char* read_internal_string();
void write_internal_string(const char* string);
void write_external_string(char* string, size_t maxLength);
void execute_function(void(*function)(void*), void* context);
void set_time_in_seconds(int seconds);
void write_internal_time_in_seconds();
@@ -0,0 +1,34 @@
################################################################################
#
# openjdk jni test
#
################################################################################
OPENJDK_JNI_TEST_DEPENDENCIES = openjdk
JNI_INCLUDE_PATH = $(BUILD_DIR)/openjdk-$(OPENJDK_VERSION)/build/linux-aarch64-server-release/jdk/include
define OPENJDK_JNI_TEST_BUILD_CMDS
# Compile Java classes and generate native headers
$(JAVAC) -d $(@D) -h $(@D) \
$(OPENJDK_JNI_TEST_PKGDIR)/JniTest.java \
$(OPENJDK_JNI_TEST_PKGDIR)/JniWrapper.java \
$(OPENJDK_JNI_TEST_PKGDIR)/JniHelper.java
# Compile shared library
$(TARGET_MAKE_ENV) $(TARGET_CC) -shared -fPIC \
-I$(JNI_INCLUDE_PATH) -I$(JNI_INCLUDE_PATH)/linux -I$(@D) \
-o $(@D)/libjni_native.so \
$(OPENJDK_JNI_TEST_PKGDIR)/JniWrapper.c \
$(OPENJDK_JNI_TEST_PKGDIR)/jni_helper.c \
$(OPENJDK_JNI_TEST_PKGDIR)/native.c
endef
define OPENJDK_JNI_TEST_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 755 $(@D)/JniTest.class $(TARGET_DIR)/usr/bin/JniTest.class
$(INSTALL) -D -m 755 $(@D)/JniWrapper.class $(TARGET_DIR)/usr/bin/JniWrapper.class
$(INSTALL) -D -m 755 $(@D)/JniHelper.class $(TARGET_DIR)/usr/bin/JniHelper.class
$(INSTALL) -D -m 755 $(@D)/libjni_native.so $(TARGET_DIR)/usr/lib/libjni_native.so
endef
$(eval $(generic-package))
@@ -0,0 +1 @@
source "$BR2_EXTERNAL_POLKIT_PATH/package/polkit-rules-test/Config.in"
@@ -0,0 +1 @@
name: POLKIT
@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_POLKIT_PATH)/package/*/*.mk))
@@ -0,0 +1,6 @@
config BR2_PACKAGE_POLKIT_RULES_TEST
bool "polkit rules test"
depends on BR2_PACKAGE_POLKIT
help
Simple test to ensure polkit is loading and enforcing rules
correctly.
@@ -0,0 +1,6 @@
#include <stdio.h>
int main(void){
printf("Hello polkit!\n");
return 0;
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
<policyconfig>
<action id="org.freedesktop.policykit.pkexec.hello-polkit">
<message>Authentication is required to run the hello world test program</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>no</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/hello-polkit</annotate>
</action>
</policyconfig>
@@ -0,0 +1,6 @@
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.policykit.pkexec.hello-polkit" &&
subject.user == "brtest") {
return polkit.Result.YES;
}
});
@@ -0,0 +1,38 @@
################################################################################
#
# polkit-rules-test
#
################################################################################
POLKIT_RULES_TEST_DEPENDENCIES = polkit
define POLKIT_RULES_TEST_USERS
brtest -1 brtest -1 =password /home/brtest /bin/sh brtest
endef
define POLKIT_RULES_TEST_BUILD_CMDS
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/initd/hello-polkit.c $(@D)/hello-polkit.c
$(TARGET_CC) $(@D)/hello-polkit.c -o $(@D)/hello-polkit
endef
# Install the rules file to /root. Test_polkit.py first tests that restarting
# timesyncd as a user fails, then moves the rules file and confirmes restarting
# timesyncd as a user succeeds.
define POLKIT_RULES_TEST_INSTALL_INIT_SYSTEMD
mkdir -p $(TARGET_DIR)/etc/polkit-1/rules.d
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/systemd/systemd-timesyncd-restart.rules \
$(TARGET_DIR)/root/systemd-timesyncd-restart.rules
endef
define POLKIT_RULES_TEST_INSTALL_INIT_SYSV
mkdir -p $(TARGET_DIR)/usr/share/polkit-1/actions/
$(INSTALL) -D $(@D)/hello-polkit $(TARGET_DIR)/usr/bin/hello-polkit
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/initd/hello-polkit.policy \
$(TARGET_DIR)/usr/share/polkit-1/actions/hello-polkit.policy
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/initd/hello-polkit.rules \
$(TARGET_DIR)/root/hello-polkit.rules
endef
$(eval $(generic-package))
@@ -0,0 +1,7 @@
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.systemd1.manage-units" &&
action.lookup("unit") == "systemd-timesyncd.service" &&
subject.user == "brtest") {
return polkit.Result.YES;
}
});
@@ -0,0 +1,7 @@
#!/bin/sh
set -e
shift
for file in "$@"; do
cp -f "${file}" "${TARGET_DIR}/root/"
done
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
# simple test which creates a dummy file system image, then use bmaptool create
# and bmaptool copy to copy it to another file
set -xeu
# create the necessary test files
dd if=/dev/zero of=disk.img bs=2M count=1
mkfs.ext4 disk.img
fallocate -d disk.img
dd if=/dev/zero of=copy.img bs=2M count=1
# do a test copy of the file system image
bmaptool create -o disk.img.bmap disk.img
bmaptool copy disk.img copy.img
cmp disk.img copy.img
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""A simple test that uses gst1-python to run a fake videotestsrc for 100
frames
"""
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib # noqa: E402
def on_message(bus, message, loop):
print('Received Gst.Message.type: {}'.format(message.type))
if message.type == Gst.MessageType.EOS:
loop.quit()
return True
def main():
# Initializes Gstreamer
Gst.init(sys.argv)
pipeline = Gst.parse_launch("videotestsrc num-buffers=100 ! fakevideosink")
bus = pipeline.get_bus()
bus.add_signal_watch()
pipeline.set_state(Gst.State.PLAYING)
loop = GLib.MainLoop()
bus.connect("message", on_message, loop)
loop.run()
pipeline.set_state(Gst.State.NULL)
if __name__ == '__main__':
main()
@@ -0,0 +1 @@
import ftdi1 # noqa
@@ -0,0 +1,10 @@
import argh
@argh.arg("foo", help="help for foo")
@argh.arg("--bar", help="help for bar")
def main(foo, bar=False):
print("{}, {}".format(foo, bar))
argh.dispatch_command(main)
@@ -0,0 +1,15 @@
import attr
@attr.s
class Obj(object):
x = attr.ib()
y = attr.ib(default=1)
obj1 = Obj(2)
assert(obj1.x == 2)
assert(obj1.y == 1)
obj2 = Obj(3, 4)
assert(obj2.x == 3)
assert(obj2.y == 4)
@@ -0,0 +1,9 @@
import augeas
a = augeas.Augeas(root="/")
hosts = a.match("/files/etc/hosts/*")
assert(hosts is not None)
assert(len(hosts) == 2)
assert(a.get("/files/etc/hosts/1/ipaddr") == "127.0.0.1")
assert(a.get("/files/etc/hosts/1/canonical") == "localhost")
@@ -0,0 +1 @@
import autobahn.wamp # noqa
@@ -0,0 +1,27 @@
from automat import MethodicalMachine
class Led(object):
_machine = MethodicalMachine()
@_machine.state()
def led_on(self):
"led is on"
@_machine.state(initial=True)
def led_off(self):
"led is off"
@_machine.input()
def turn_on(self):
"turn the led on"
@_machine.output()
def _light(self):
print("light")
led_off.upon(turn_on, enter=led_on, outputs=[_light])
led = Led()
led.turn_on()
@@ -0,0 +1,23 @@
from io import BytesIO
from avro.schema import Parse
from avro.io import DatumReader, BinaryDecoder
schema = Parse("""{
"namespace": "org.buildroot.package.python_avro",
"type": "record",
"name": "Developer",
"fields": [
{"name": "email", "type": "string"},
{"name": "maintainer_of", "type": "string"}
]
}""")
example = b'<titouan.christophe@railnova.eu\x16python_avro'
reader = DatumReader(schema)
deserialized = reader.read(BinaryDecoder(BytesIO(example)))
assert deserialized == {
'email': 'titouan.christophe@railnova.eu',
'maintainer_of': 'python_avro',
}
@@ -0,0 +1,6 @@
import bitstring
value = bitstring.BitArray("uint:12=42")
assert(value.hex == "02a")
assert(value.bin == "000000101010")
assert(value.uint == 42)
@@ -0,0 +1,2 @@
import boto3
s3 = boto3.resource('s3')
@@ -0,0 +1,3 @@
import botocore.session
session = botocore.session.get_session()
client = session.create_client('ec2', region_name="us-east-1")
@@ -0,0 +1,6 @@
import can
msg = can.Message(arbitration_id=0xc0ffee,
data=[0, 25, 0, 1, 3, 1, 4, 1],
is_extended_id=True)
assert(msg is not None)
@@ -0,0 +1,10 @@
import cbor
with open("/tmp/data.cbor", "rb") as f:
serialized = f.read()
data = cbor.loads(serialized)
print(data)
assert(data["name"] == "python-cbor")
assert(data["versions"] == ["1", "2"])
assert(data["group"]["is_a_package"] is True)
assert(data["group"]["value"] == 42)
@@ -0,0 +1,14 @@
import cbor
data = {
"name": "python-cbor",
"versions": ["1", "2"],
"group": {
"is_a_package": True,
"value": 42
}
}
serialized = cbor.dumps(data)
print(serialized.decode(errors="ignore"))
with open("/tmp/data.cbor", "wb") as f:
f.write(serialized)
@@ -0,0 +1,12 @@
import click
@click.command()
@click.argument("foo")
@click.option("--bar", is_flag=True, help="help for bar")
def main(foo, bar):
click.echo("{}, {}".format(foo, bar))
if __name__ == '__main__':
main()
@@ -0,0 +1,8 @@
from colorzero import Color
red = Color('red')
green = Color('lime')
blue = Color('blue')
assert(red.rgb == (1.0, 0.0, 0.0))
assert(green.rgb == (0.0, 1.0, 0.0))
assert(blue.rgb == (0.0, 0.0, 1.0))
@@ -0,0 +1,19 @@
from constantly import ValueConstant, Values
class RESULT(Values):
OK = ValueConstant(0)
FAIL = ValueConstant(-1)
@classmethod
def get(cls, rc):
if rc == 0:
return cls.OK
else:
return cls.FAIL
print(list(RESULT.iterconstants()))
assert(RESULT.OK < RESULT.FAIL)
assert(RESULT.OK.value > RESULT.FAIL.value)
assert(RESULT.get(-5) == RESULT.FAIL)
@@ -0,0 +1,5 @@
import os
import crossbar
os.environ["AUTOBAHN_USE_UMSGPACK"] = "1"
crossbar.run(["version"])
@@ -0,0 +1,3 @@
from cryptography.fernet import Fernet
key = Fernet.generate_key()
f = Fernet(key)
@@ -0,0 +1,44 @@
import asyncio
from dbus_next.aio import MessageBus
from dbus_next.service import ServiceInterface, method
import dbus_next.introspection as intr
from dbus_next import BusType
class SampleInterface(ServiceInterface):
def __init__(self):
super().__init__('test.interface')
@method()
def Ping(self):
pass
@method()
def ConcatStrings(self, what1: 's', what2: 's') -> 's': # noqa: F821
return what1 + what2
async def main():
bus_name = 'dbus.next.sample'
bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
bus2 = await MessageBus(bus_type=BusType.SYSTEM).connect()
await bus.request_name(bus_name)
service_interface = SampleInterface()
bus.export('/test/path', service_interface)
introspection = await bus2.introspect(bus_name, '/test/path')
assert type(introspection) is intr.Node
obj = bus2.get_proxy_object(bus_name, '/test/path', introspection)
interface = obj.get_interface(service_interface.name)
result = await interface.call_ping()
assert result is None
result = await interface.call_concat_strings('hello ', 'world')
assert result == 'hello world'
asyncio.run(main())
@@ -0,0 +1 @@
import django # noqa: F401
@@ -0,0 +1,7 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
@@ -0,0 +1,18 @@
from flask import Flask
from flask_expects_json import expects_json
app = Flask(__name__)
schema = {
'type': 'object',
'properties': {
'name': {'type': 'string'},
'email': {'type': 'string'},
},
'required': ['name', 'email']
}
@app.route('/', methods=['POST'])
@expects_json(schema)
def hello_world():
return 'Hello, World!'
@@ -0,0 +1 @@
from git import * # noqa
@@ -0,0 +1 @@
from gitdb import * # noqa
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
"""A simple test that uses python-gobject to find the path of sh."""
from gi.repository import GLib
def main():
sh_path = GLib.find_program_in_path('sh')
if sh_path == "/bin/sh":
return True
return False
if __name__ == '__main__':
main()
@@ -0,0 +1,5 @@
from gpiozero import pi_info
piBoardInfo = pi_info('a020d3') # 3B+
assert(piBoardInfo.model == '3B+')
@@ -0,0 +1,3 @@
import incremental
v = incremental.Version("package", 1, 2, 3, release_candidate=4)
assert(str(v) == "[package, version 1.2.3.rc4]")
@@ -0,0 +1,5 @@
from passlib.hash import pbkdf2_sha256
hash = pbkdf2_sha256.hash("password")
assert(pbkdf2_sha256.verify("passWord", hash) is False)
assert(pbkdf2_sha256.verify("password", hash) is True)
@@ -0,0 +1,8 @@
import pexpect
p = pexpect.spawn(["login"])
p.expect("login:")
p.sendline("wrong")
p.expect("Password:")
p.sendline("wrong")
p.expect("Login incorrect")
@@ -0,0 +1,3 @@
import nacl.utils
nonce = nacl.utils.random(16)
@@ -0,0 +1,25 @@
import pytest
x = 1
@pytest.fixture()
def f1():
global x
x = 2
yield 15
x = 3
def test_1():
assert x == 1
def test_2(f1):
assert x == 2
assert f1 == 15
def test_3():
assert x == 3
@@ -0,0 +1,31 @@
import asyncio
import pytest
x = 1
@pytest.fixture()
def f1():
global x
x = 2
yield 15
x = 3
@pytest.mark.asyncio
async def test_1():
assert x == 1
@pytest.mark.asyncio
async def test_2(f1):
assert x == 2
assert f1 == 15
@pytest.mark.asyncio
async def test_3():
assert x == 3
await asyncio.sleep(0.1)
assert x == 3
@@ -0,0 +1,10 @@
import yaml
with open("/tmp/data.yml", "rb") as f:
serialized = f.read()
data = yaml.load(serialized)
print(data)
assert(data["name"] == "python-pyyaml")
assert(data["versions"] == ["1", "2"])
assert(data["group"]["is_a_package"] is True)
assert(data["group"]["value"] == 42)
@@ -0,0 +1,14 @@
import yaml
data = {
"name": "python-pyyaml",
"versions": ["1", "2"],
"group": {
"is_a_package": True,
"value": 42
}
}
serialized = yaml.dump(data, default_flow_style=False)
print(serialized)
with open("/tmp/data.yml", "w") as f:
f.write(serialized)
@@ -0,0 +1,6 @@
try:
import RPi.GPIO # noqa
except RuntimeError as e:
assert(str(e) == 'This module can only be run on a Raspberry Pi!')
else:
raise RuntimeError('Import succeeded when it should not have!')
@@ -0,0 +1,2 @@
import rsa
(pubkey, privkey) = rsa.newkeys(512)
@@ -0,0 +1,2 @@
from service_identity import VerificationError # noqa
from service_identity.pyopenssl import verify_hostname # noqa
@@ -0,0 +1,6 @@
# Taken from smmap/test/test_tutorial.py
import smmap
mman = smmap.SlidingWindowMapManager()
assert mman.num_file_handles() == 0
assert mman.mapped_memory_size() == 0
@@ -0,0 +1,6 @@
import subprocess32
output = subprocess32.check_output(["ls", "-l", "/dev/null"])
print(output)
assert("/dev/null" in output)
assert("No such" not in output)
@@ -0,0 +1,16 @@
from twisted.internet import reactor
import treq
def done(response):
print(response.code)
reactor.stop()
def err(fail):
print(fail.value)
reactor.stop()
treq.get("https://localhost").addCallback(done).addErrback(err)
reactor.run()
@@ -0,0 +1,9 @@
from twisted.internet import protocol, reactor, endpoints
class F(protocol.Factory):
pass
endpoints.serverFromString(reactor, "tcp:1234").listen(F())
reactor.run()
@@ -0,0 +1,3 @@
import txaio
txaio.use_asyncio()
f0 = txaio.create_future()
@@ -0,0 +1,3 @@
import txaio
txaio.use_twisted()
f0 = txaio.create_future()
@@ -0,0 +1 @@
import txtorcon # noqa
@@ -0,0 +1,10 @@
import ubjson
with open("/tmp/data.json", "rb") as f:
serialized = f.read()
data = ubjson.loadb(serialized)
print(data)
assert(data["name"] == "python-ubjson")
assert(data["versions"] == ["1", "2"])
assert(data["group"]["is_a_package"] is True)
assert(data["group"]["value"] == 42)
@@ -0,0 +1,14 @@
import ubjson
data = {
"name": "python-ubjson",
"versions": ["1", "2"],
"group": {
"is_a_package": True,
"value": 42
}
}
serialized = ubjson.dumpb(data)
print(serialized)
with open("/tmp/data.json", "wb") as f:
f.write(serialized)
@@ -0,0 +1,11 @@
import unittest
import xmlrunner
class Test1(unittest.TestCase):
def test_something(self):
self.assertTrue(True)
if __name__ == '__main__':
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
@@ -0,0 +1,39 @@
import os
import infra.basetest
BASIC_TOOLCHAIN_CONFIG_HEADERS_AT_LEAST_3_14 = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2019.05.1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
"""
class TestAtop(infra.basetest.BRTest):
config = BASIC_TOOLCHAIN_CONFIG_HEADERS_AT_LEAST_3_14 + \
"""
BR2_PACKAGE_ATOP=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", cpio_file])
self.emulator.login()
cmd = "atop -V | grep '^Version'"
self.assertRunOk(cmd)
cmd = "atop -a 1 2 | grep '% *atop *$'"
self.assertRunOk(cmd)
@@ -0,0 +1,92 @@
import os
import infra
import subprocess
from infra.basetest import BRTest
class TestBmapTools(BRTest):
__test__ = False
sample_script = "tests/package/sample_bmap_tools.sh"
copy_script = 'tests/package/copy-sample-script-to-target.sh'
config = \
"""
BR2_arm=y
BR2_cortex_a8=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_BMAP_TOOLS=y
BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="65536"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_UTIL_LINUX=y
BR2_PACKAGE_UTIL_LINUX_FALLOCATE=y
BR2_PACKAGE_E2FSPROGS=y
BR2_PACKAGE_UTIL_LINUX_LIBUUID=y
""".format(infra.filepath(copy_script),
infra.filepath(sample_script))
timeout = 60
def login(self):
img = os.path.join(self.builddir, "images", "rootfs.ext4")
self.emulator.boot(arch="armv7",
kernel="builtin",
kernel_cmdline=["root=/dev/mmcblk0",
"rootfstype=ext4"],
options=["-drive", "file={},if=sd,format=raw".format(img)])
self.emulator.login()
def test_run(self):
self.login()
cmd = "/root/{}".format(os.path.basename(self.sample_script))
self.assertRunOk(cmd, timeout=20)
class TestPy2BmapTools(TestBmapTools):
__test__ = True
config = TestBmapTools.config + \
"""
BR2_PACKAGE_PYTHON=y
"""
class TestPy3BmapTools(TestBmapTools):
__test__ = True
config = TestBmapTools.config + \
"""
BR2_PACKAGE_PYTHON3=y
"""
class TestHostBmapTools(BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_PACKAGE_HOST_BMAP_TOOLS=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_ROOTFS_EXT2=y
"""
def test_run(self):
bmap_x = os.path.join(self.b.builddir, "host", "bin", "bmaptool")
src_f = os.path.join(self.b.builddir, "images", "rootfs.ext2")
dst_f = os.path.join(self.b.builddir, "images", "rootfs.ext2.copy")
map_f = os.path.join(self.b.builddir, "images", "rootfs.ext2.bmap")
ret = subprocess.call([bmap_x, "create", "-o", map_f, src_f],
stdout=self.b.logfile,
stderr=self.b.logfile)
self.assertEqual(ret, 0)
ret = subprocess.call([bmap_x, "copy", src_f, dst_f],
stdout=self.b.logfile,
stderr=self.b.logfile)
self.assertEqual(ret, 0)
with open(src_f, 'rb') as f:
src = f.read()
with open(dst_f, 'rb') as f:
dst = f.read()
self.assertEqual(src, dst)
@@ -0,0 +1,49 @@
import os
from tests.package.test_python import TestPythonPackageBase
INI_FILE_CONTENT = """
[section]
param = this-is-the-magic-value
other = dont care
"""
class TestCrudiniBase(TestPythonPackageBase):
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_CRUDINI=y
"""
def test_run(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5", kernel="builtin",
options=["-initrd", img])
self.emulator.login()
# 1. Create some sample .ini file
cmd = "echo -e '%s' > config.ini" % INI_FILE_CONTENT
_, ret = self.emulator.run(cmd)
self.assertEqual(ret, 0)
# 2. Attempt to get the value
out, ret = self.emulator.run("crudini --get config.ini section param")
self.assertEqual(ret, 0)
self.assertEqual(out, ['this-is-the-magic-value'])
class TestCrudiniPy2(TestCrudiniBase):
__test__ = True
config = TestCrudiniBase.config + \
"""
BR2_PACKAGE_PYTHON=y
"""
class TestCrudiniPy3(TestCrudiniBase):
__test__ = True
config = TestCrudiniBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
"""
@@ -0,0 +1,64 @@
import os
import infra.basetest
class TestDockerCompose(infra.basetest.BRTest):
config = \
"""
BR2_x86_64=y
BR2_x86_corei7=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_CORE_I7_GLIBC_STABLE=y
BR2_SYSTEM_DHCP="eth0"
BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="{}"
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_DOCKER_CLI=y
BR2_PACKAGE_DOCKER_COMPOSE=y
BR2_PACKAGE_DOCKER_ENGINE=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
# BR2_TARGET_ROOTFS_TAR is not set
""".format(
infra.filepath("tests/package/copy-sample-script-to-target.sh"),
infra.filepath("conf/docker-compose.yml"),
infra.filepath("conf/docker-compose-kernel.config"))
def wait_for_dockerd(self):
# dockerd takes a while to start up
_, _ = self.emulator.run('while [ ! -e /var/run/docker.sock ]; do sleep 1; done', 120)
def docker_test(self):
# will download container if not available, which may take some time
self.assertRunOk('docker run --rm -p 8888:8888 busybox:latest /bin/true', 120)
def docker_compose_test(self):
# will download container if not available, which may take some time
self.assertRunOk('docker-compose up -d', 120)
# container may take some time to start
self.assertRunOk('while ! docker inspect root_busybox_1 2>&1 >/dev/null; do sleep 1; done', 120)
self.assertRunOk('wget -O /tmp/busybox http://127.0.0.1/busybox', 120)
self.assertRunOk('cmp /bin/busybox /tmp/busybox', 120)
def test_run(self):
kernel = os.path.join(self.builddir, "images", "bzImage")
rootfs = os.path.join(self.builddir, "images", "rootfs.ext2")
self.emulator.boot(arch="x86_64",
kernel=kernel,
kernel_cmdline=["root=/dev/vda", "console=ttyS0"],
options=["-cpu", "Nehalem",
"-m", "512M",
"-device", "virtio-rng-pci",
"-drive", "file={},format=raw,if=virtio".format(rootfs),
"-net", "nic,model=virtio",
"-net", "user"])
self.emulator.login()
self.wait_for_dockerd()
self.docker_test()
self.docker_compose_test()
@@ -0,0 +1,30 @@
import os
import infra.basetest
class TestDropbear(infra.basetest.BRTest):
passwd = "testpwd"
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_TARGET_GENERIC_ROOT_PASSWD="{}"
BR2_SYSTEM_DHCP="eth0"
BR2_PACKAGE_DROPBEAR=y
BR2_PACKAGE_SSHPASS=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
""".format(passwd)
def test_run(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", img,
"-net", "nic",
"-net", "user"])
self.emulator.login(self.passwd)
cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22"
self.assertRunOk(cmd)
cmd = "sshpass -p {} ssh -y localhost /bin/true".format(self.passwd)
self.assertRunOk(cmd)
@@ -0,0 +1,37 @@
import os
import infra.basetest
class TestDtbocfg(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.10.7"
BR2_LINUX_KERNEL_USE_DEFCONFIG=y
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
BR2_PACKAGE_DTBOCFG=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio")
kernel = os.path.join(self.builddir, "images", "zImage")
kernel_cmdline = ["console=ttyAMA0"]
dtb = infra.download(self.downloaddir, "vexpress-v2p-ca9.dtb")
options = ["-M", "vexpress-a9", "-dtb", dtb, "-initrd", img]
self.emulator.boot(arch="armv7", kernel=kernel,
kernel_cmdline=kernel_cmdline,
options=options)
self.emulator.login()
self.assertRunOk("modprobe dtbocfg.ko")
self.assertRunOk("mkdir /tmp/config && mount -t configfs none /tmp/config")
# Check that overlays directory is present.
# From dtbocfg site (https://github.com/ikwzm/dtbocfg):
# If /config/device-tree/overlays is created, it is ready to use
# dtbocfg
self.assertRunOk("ls /tmp/config/device-tree/overlays/")
@@ -0,0 +1,23 @@
import os
import infra.basetest
class TestExecline(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_PACKAGE_EXECLINE=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", img])
self.emulator.login()
output, exit_code = self.emulator.run("execlineb -c 'echo hello world'")
self.assertEqual(exit_code, 0)
self.assertEqual(output[0].strip(), "hello world")
+215
View File
@@ -0,0 +1,215 @@
import os
import infra.basetest
class BaseGdb(infra.basetest.BRTest):
def verify_host_gdb(self, prefix="arm-linux"):
cmd = ["host/bin/%s-gdb" % prefix, "--version"]
# We don't check the return value, as it automatically raises
# an exception if the command returns with a non-zero value
infra.run_cmd_on_host(self.builddir, cmd)
def boot(self):
img = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", img,
"-net", "nic",
"-net", "user"])
self.emulator.login()
def verify_gdbserver(self):
cmd = "gdbserver --version"
self.assertRunOk(cmd)
def verify_gdb(self):
cmd = "gdb --version"
self.assertRunOk(cmd)
class TestGdbHostOnlyDefault(BaseGdb):
config = \
infra.basetest.MINIMAL_CONFIG + \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
"""
def test_run(self):
self.verify_host_gdb()
class TestGdbHostOnlyAllFeatures(BaseGdb):
config = \
infra.basetest.MINIMAL_CONFIG + \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_PACKAGE_HOST_GDB_TUI=y
BR2_PACKAGE_HOST_GDB_PYTHON3=y
BR2_PACKAGE_HOST_GDB_SIM=y
"""
def test_run(self):
self.verify_host_gdb()
class TestGdbserverOnly(BaseGdb):
config = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_GDB=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
self.boot()
self.verify_gdbserver()
class TestGdbFullTarget(BaseGdb):
config = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_DEBUGGER=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
self.boot()
self.verify_gdb()
class TestGdbHostOnly9x(BaseGdb):
config = \
infra.basetest.MINIMAL_CONFIG + \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_9_2=y
"""
def test_run(self):
self.verify_host_gdb()
class TestGdbHostGdbserver9x(BaseGdb):
config = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_9_2=y
BR2_PACKAGE_GDB=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
self.verify_host_gdb()
self.boot()
self.verify_gdbserver()
class TestGdbHostGdbTarget9x(BaseGdb):
config = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_9_2=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_DEBUGGER=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
self.verify_host_gdb()
self.boot()
self.verify_gdb()
class TestGdbHostOnly11x(BaseGdb):
config = \
infra.basetest.MINIMAL_CONFIG + \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_11=y
"""
def test_run(self):
self.verify_host_gdb()
class TestGdbHostGdbserver11x(BaseGdb):
config = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_11=y
BR2_PACKAGE_GDB=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
self.verify_host_gdb()
self.boot()
self.verify_gdbserver()
class TestGdbHostGdbTarget11x(BaseGdb):
config = \
"""
BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_HOST_GDB=y
BR2_GDB_VERSION_11=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_DEBUGGER=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def test_run(self):
self.verify_host_gdb()
self.boot()
self.verify_gdb()
class TestGdbArc(BaseGdb):
config = \
"""
BR2_arcle=y
BR2_archs4x_rel31=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_PACKAGE_HOST_GDB=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_SERVER=y
BR2_PACKAGE_GDB_DEBUGGER=y
"""
def test_run(self):
self.verify_host_gdb("arc-linux")
@@ -0,0 +1,64 @@
import os
import infra.basetest
GLXINFO_TIMEOUT = 120
class TestGlxinfo(infra.basetest.BRTest):
config = \
"""
BR2_x86_core2=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://toolchains.bootlin.com/downloads/releases/toolchains/x86-core2/tarballs/x86-core2--glibc--bleeding-edge-2018.11-1.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_14=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.204"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86/linux.config"
BR2_PACKAGE_MESA3D_DEMOS=y
BR2_PACKAGE_MESA3D=y
BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_SWRAST=y
BR2_PACKAGE_MESA3D_OPENGL_GLX=y
BR2_PACKAGE_XORG7=y
BR2_PACKAGE_XSERVER_XORG_SERVER=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
BR2_TARGET_ROOTFS_EXT2=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_ROOTFS_OVERLAY="{}"
""".format(
infra.filepath("tests/package/test_glxinfo/rootfs-overlay"))
def wait_for_xserver(self):
# xserver takes some time to start up
# The test case fail here if for some reason xserver is not properly installed
_, _ = self.emulator.run('while [ ! -e /var/run/xorg.pid ]; do sleep 1; done', 120)
def login(self):
img = os.path.join(self.builddir, "images", "rootfs.ext2")
kern = os.path.join(self.builddir, "images", "bzImage")
# glxinfo overallocate memory and the minimum that seemed to work was 512MB
self.emulator.boot(arch="i386",
kernel=kern,
kernel_cmdline=["root=/dev/vda console=ttyS0"],
options=["-M", "pc", "-m", "512", "-drive", "file={},if=virtio,format=raw".format(img)])
self.emulator.login()
def test_run(self):
self.login()
self.wait_for_xserver()
# The test case verifies that the xserver with GLX is working
cmd = "glxinfo -B -display :0"
output, exit_code = self.emulator.run(cmd, GLXINFO_TIMEOUT)
self.assertEqual(exit_code, 0)
for line in output:
self.assertNotIn("Error", line)
# Error case: "Error: couldn't find RGB GLX visual or fbconfig"
@@ -0,0 +1,11 @@
# Xorg does not implement real dynamic linking and requires that its
# modules get loaded in the right order.
# https://forums.gentoo.org/viewtopic-p-8245578.html#8245578
Section "Module"
Load "vgahw"
Load "fb"
Load "shadowfb"
Load "shadow"
Load "glamoregl"
EndSection
@@ -0,0 +1,31 @@
import os
from tests.package.test_python import TestPythonPackageBase
class TestGst1Python(TestPythonPackageBase):
__test__ = True
config = \
"""
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y
BR2_PACKAGE_GSTREAMER1=y
BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_VIDEOTESTSRC=y
BR2_PACKAGE_GST1_PLUGINS_BAD=y
BR2_PACKAGE_GST1_PLUGINS_BAD_PLUGIN_DEBUGUTILS=y
BR2_PACKAGE_GST1_PYTHON=y
BR2_PACKAGE_PYTHON3=y
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def login(self):
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv7",
kernel="builtin",
options=["-initrd", cpio_file])
self.emulator.login()
sample_scripts = ["tests/package/sample_gst1_python.py"]
timeout = 200
@@ -0,0 +1,22 @@
from tests.package.test_python import TestPythonBase
#
# The following pythong tests are not being used here:
#
# - version_test: IPython does not support --version option
#
# - zlib_test: IPython does not return a non-zero code the way CPython
# does, so this test ends up being a false-negative
class TestIPythonPy3(TestPythonBase):
config = TestPythonBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_IPYTHON=y
"""
interpreter = "ipython"
def test_run(self):
self.login()
self.math_floor_test(40)
self.libc_time_test(40)
@@ -0,0 +1,25 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Libftdi1(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_LIBFTDI1=y
BR2_PACKAGE_LIBFTDI1_PYTHON_BINDINGS=y
"""
sample_scripts = ["tests/package/sample_libftdi1.py"]
timeout = 40
class TestPythonPy3Libftdi1(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_LIBFTDI1=y
BR2_PACKAGE_LIBFTDI1_PYTHON_BINDINGS=y
"""
sample_scripts = ["tests/package/sample_libftdi1.py"]
timeout = 40
@@ -0,0 +1,27 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLPeg(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LPEG=y
"""
def test_run(self):
self.login()
self.module_test("lpeg")
self.module_test("re")
class TestLuajitLPeg(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LPEG=y
"""
def test_run(self):
self.login()
self.module_test("lpeg")
self.module_test("re")
@@ -0,0 +1,25 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLsqlite3(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LSQLITE3=y
"""
def test_run(self):
self.login()
self.module_test("lsqlite3")
class TestLuajitLsqlite3(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LSQLITE3=y
"""
def test_run(self):
self.login()
self.module_test("lsqlite3")
+58
View File
@@ -0,0 +1,58 @@
import os
import infra.basetest
class TestLuaBase(infra.basetest.BRTest):
config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
"""
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
"""
def login(self):
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
self.emulator.boot(arch="armv5",
kernel="builtin",
options=["-initrd", cpio_file])
self.emulator.login()
def version_test(self, version):
cmd = "lua -v"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
self.assertIn(version, output[0])
def g_version_test(self, expected):
cmd = "lua -e 'print(_G._VERSION)'"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
self.assertEqual(output[0], expected)
def module_test(self, module, script="a=1"):
cmd = "lua -l {} -e '{}'".format(module, script)
self.assertRunOk(cmd)
class TestLua(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
"""
def test_run(self):
self.login()
self.version_test('Lua 5.3')
self.g_version_test('Lua 5.3')
class TestLuajit(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
"""
def test_run(self):
self.login()
self.version_test('LuaJIT 2')
self.g_version_test('Lua 5.1')
@@ -0,0 +1,27 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLuaAugeas(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_AUGEAS=y
BR2_PACKAGE_LUA_AUGEAS=y
"""
def test_run(self):
self.login()
self.module_test("augeas")
class TestLuajitLuaAugeas(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_AUGEAS=y
BR2_PACKAGE_LUA_AUGEAS=y
"""
def test_run(self):
self.login()
self.module_test("augeas")
@@ -0,0 +1,59 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLuaCqueues(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_CQUEUES=y
"""
def test_run(self):
self.login()
self.module_test("_cqueues")
self.module_test("cqueues")
self.module_test("cqueues.auxlib")
self.module_test("cqueues.condition")
self.module_test("cqueues.dns")
self.module_test("cqueues.dns.config")
self.module_test("cqueues.dns.hints")
self.module_test("cqueues.dns.hosts")
self.module_test("cqueues.dns.packet")
self.module_test("cqueues.dns.record")
self.module_test("cqueues.dns.resolver")
self.module_test("cqueues.dns.resolvers")
self.module_test("cqueues.errno")
self.module_test("cqueues.notify")
self.module_test("cqueues.promise")
self.module_test("cqueues.signal")
self.module_test("cqueues.socket")
self.module_test("cqueues.thread")
class TestLuajitLuaCqueues(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_CQUEUES=y
"""
def test_run(self):
self.login()
self.module_test("_cqueues")
self.module_test("cqueues")
self.module_test("cqueues.auxlib")
self.module_test("cqueues.condition")
self.module_test("cqueues.dns")
self.module_test("cqueues.dns.config")
self.module_test("cqueues.dns.hints")
self.module_test("cqueues.dns.hosts")
self.module_test("cqueues.dns.packet")
self.module_test("cqueues.dns.record")
self.module_test("cqueues.dns.resolver")
self.module_test("cqueues.dns.resolvers")
self.module_test("cqueues.errno")
self.module_test("cqueues.notify")
self.module_test("cqueues.promise")
self.module_test("cqueues.signal")
self.module_test("cqueues.socket")
self.module_test("cqueues.thread")
@@ -0,0 +1,27 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLuacURL(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_CURL=y
"""
def test_run(self):
self.login()
self.module_test("cURL")
self.module_test("lcurl")
class TestLuajitLuacURL(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_CURL=y
"""
def test_run(self):
self.login()
self.module_test("cURL")
self.module_test("lcurl")
@@ -0,0 +1,31 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLuaGD(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_GD=y
BR2_PACKAGE_FONTCONFIG=y
BR2_PACKAGE_JPEG=y
BR2_PACKAGE_LIBPNG=y
"""
def test_run(self):
self.login()
self.module_test("gd")
class TestLuajitLuaGD(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_GD=y
BR2_PACKAGE_FONTCONFIG=y
BR2_PACKAGE_JPEG=y
BR2_PACKAGE_LIBPNG=y
"""
def test_run(self):
self.login()
self.module_test("gd")
@@ -0,0 +1,37 @@
from tests.package.test_lua import TestLuaBase
class TestLuaHttp(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_HTTP=y
"""
def test_run(self):
self.login()
self.module_test("http.version", script="local ver=require[[http.version]]; print(ver.name, ver.version)")
self.module_test("http.client")
self.module_test("http.cookie")
self.module_test("http.proxies")
self.module_test("http.server")
self.module_test("http.socks")
self.module_test("http.websocket")
class TestLuajitHttp(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_HTTP=y
"""
def test_run(self):
self.login()
self.module_test("http.version", script="local ver=require[[http.version]]; print(ver.name, ver.version)")
self.module_test("http.client")
self.module_test("http.cookie")
self.module_test("http.proxies")
self.module_test("http.server")
self.module_test("http.socks")
self.module_test("http.websocket")
@@ -0,0 +1,25 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLunix(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_LUNIX=y
"""
def test_run(self):
self.login()
self.module_test("unix")
class TestLuajitLunix(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_LUNIX=y
"""
def test_run(self):
self.login()
self.module_test("unix")
@@ -0,0 +1,27 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLuaLyaml(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_LYAML=y
"""
def test_run(self):
self.login()
self.module_test("yaml")
self.module_test("lyaml")
class TestLuajitLuaLyaml(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_LYAML=y
"""
def test_run(self):
self.login()
self.module_test("yaml")
self.module_test("lyaml")
@@ -0,0 +1,41 @@
from tests.package.test_lua import TestLuaBase
class TestLuaLuaSDL2(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUA=y
BR2_PACKAGE_LUA_SDL2=y
BR2_PACKAGE_SDL2_IMAGE=y
BR2_PACKAGE_SDL2_MIXER=y
BR2_PACKAGE_SDL2_NET=y
BR2_PACKAGE_SDL2_TTF=y
"""
def test_run(self):
self.login()
self.module_test("SDL")
self.module_test("SDL.image")
self.module_test("SDL.mixer")
self.module_test("SDL.net")
self.module_test("SDL.ttf")
class TestLuajitLuaSDL2(TestLuaBase):
config = TestLuaBase.config + \
"""
BR2_PACKAGE_LUAJIT=y
BR2_PACKAGE_LUA_SDL2=y
BR2_PACKAGE_SDL2_IMAGE=y
BR2_PACKAGE_SDL2_MIXER=y
BR2_PACKAGE_SDL2_NET=y
BR2_PACKAGE_SDL2_TTF=y
"""
def test_run(self):
self.login()
self.module_test("SDL")
self.module_test("SDL.image")
self.module_test("SDL.mixer")
self.module_test("SDL.net")
self.module_test("SDL.ttf")

Some files were not shown because too many files have changed in this diff Show More