Initial Commit

- initial default booting image
This commit is contained in:
2026-11-06 20:45:42 +01:00
commit b8783708ae
15201 changed files with 602532 additions and 0 deletions

View File

@@ -0,0 +1 @@
source "$BR2_EXTERNAL_CLANG_COMPILER_RT_PATH/package/libfuzzer/Config.in"

View File

@@ -0,0 +1 @@
name: CLANG_COMPILER_RT

View File

@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_CLANG_COMPILER_RT_PATH)/package/*/*.mk))

View File

@@ -0,0 +1,8 @@
config BR2_PACKAGE_LIBFUZZER
bool "libfuzzer"
help
This project aims at hosting tutorials,
examples, discussions, research proposals,
and other resources related to fuzzing.
https://github.com/google/fuzzing

View File

@@ -0,0 +1,2 @@
sha256 c71360c3b1ba1d88b28b0b3cb3a1744d251b87a12f2881224cc53ec26eb7a2db libfuzzer-cec02db916d21baa4db5b8d262d78848b3a35f4b.tar.gz
sha256 cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE

View File

@@ -0,0 +1,24 @@
################################################################################
#
# libfuzzer
#
################################################################################
LIBFUZZER_VERSION = cec02db916d21baa4db5b8d262d78848b3a35f4b
LIBFUZZER_SITE = $(call github,google,fuzzing,$(LIBFUZZER_VERSION))
LIBFUZZER_LICENSE = Apache-2.0
LIBFUZZER_LICENSE_FILES = LICENSE
LIBFUZZER_DEPENDENCIES = compiler-rt
define LIBFUZZER_BUILD_CMDS
$(HOST_DIR)/bin/clang++ --sysroot=$(STAGING_DIR) \
-fsanitize=address,fuzzer \
$(@D)/tutorial/libFuzzer/fuzz_me.cc \
-o $(@D)/fuzz_me
endef
define LIBFUZZER_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 755 $(@D)/fuzz_me $(TARGET_DIR)/usr/bin/fuzz_me
endef
$(eval $(generic-package))

View File

@@ -0,0 +1 @@
source "$BR2_EXTERNAL_GUMBO_PARSER_PATH/package/gumbo-parser-test/Config.in"

View File

@@ -0,0 +1 @@
name: GUMBO_PARSER

View File

@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_GUMBO_PARSER_PATH)/package/*/*.mk))

View File

@@ -0,0 +1,7 @@
config BR2_PACKAGE_GUMBO_PARSER_TEST
bool "gumbo-parser-test"
depends on BR2_PACKAGE_GUMBO_PARSER
help
Test program for gumbo-parser library.
This package builds a simple test program that demonstrates
basic HTML parsing functionality using gumbo-parser.

View File

@@ -0,0 +1,19 @@
################################################################################
#
# gumbo-parser-test
#
################################################################################
GUMBO_PARSER_TEST_DEPENDENCIES = gumbo-parser
define GUMBO_PARSER_TEST_BUILD_CMDS
$(TARGET_CC) $(TARGET_CFLAGS) -o $(@D)/gumbo_test \
$(GUMBO_PARSER_TEST_PKGDIR)/gumbo_test.c \
$(TARGET_LDFLAGS) -lgumbo
endef
define GUMBO_PARSER_TEST_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/gumbo_test $(TARGET_DIR)/usr/bin/gumbo_test
endef
$(eval $(generic-package))

View File

@@ -0,0 +1,40 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gumbo.h>
static void search_for_title(GumboNode* node) {
if (node->type != GUMBO_NODE_ELEMENT) {
return;
}
if (node->v.element.tag == GUMBO_TAG_TITLE) {
GumboNode* text = node->v.element.children.data[0];
if (text->type == GUMBO_NODE_TEXT) {
printf("Found title: %s\n", text->v.text.text);
}
return;
}
GumboVector* children = &node->v.element.children;
for (unsigned int i = 0; i < children->length; ++i) {
search_for_title(children->data[i]);
}
}
int main() {
const char* html = "<html><head><title>Test HTML</title></head><body><p>Hello World</p></body></html>";
GumboOutput* output = gumbo_parse(html);
if (output == NULL) {
printf("HTML parsing failed\n");
return 1;
}
printf("HTML parsing successful\n");
search_for_title(output->root);
gumbo_destroy_output(&kGumboDefaultOptions, output);
return 0;
}

View File

@@ -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"

View File

@@ -0,0 +1 @@
name: OPENJDK

View File

@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_OPENJDK_PATH)/package/*/*.mk))

View File

@@ -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

View File

@@ -0,0 +1,7 @@
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, World");
}
}

View File

@@ -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))

View File

@@ -0,0 +1,5 @@
config BR2_PACKAGE_OPENJDK_JNI_TEST
bool "openjdk JNI test"
depends on BR2_PACKAGE_OPENJDK
help
Tests openjdk JNI support

View File

@@ -0,0 +1,9 @@
public class JniHelper
{
public void HelloManagedWorld()
{
stringMember = "Hello, Managed World";
}
public String stringMember = "Set from Java";
}

View File

@@ -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 = 0x00180000;
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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -0,0 +1,41 @@
#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)
{
struct timespec timeToSet = { 0, 0 };
timeToSet.tv_sec = seconds;
clock_settime(CLOCK_REALTIME, &timeToSet);
}
void write_internal_time_in_seconds()
{
time_t systemTime = time(NULL);
snprintf(buffer, CHAR_BUFFER_SIZE, "%u", systemTime);
}

View File

@@ -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();

View File

@@ -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))

View File

@@ -0,0 +1 @@
source "$BR2_EXTERNAL_POLKIT_PATH/package/polkit-rules-test/Config.in"

View File

@@ -0,0 +1 @@
name: POLKIT

View File

@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_POLKIT_PATH)/package/*/*.mk))

View File

@@ -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.

View File

@@ -0,0 +1,6 @@
#include <stdio.h>
int main(void){
printf("Hello polkit!\n");
return 0;
}

View File

@@ -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>

View File

@@ -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;
}
});

View File

@@ -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))

View File

@@ -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;
}
});

View File

@@ -0,0 +1 @@
source "$BR2_EXTERNAL_PYTHON_PYBIND_PATH/package/python-pybind-example/Config.in"

View File

@@ -0,0 +1 @@
name: PYTHON_PYBIND

View File

@@ -0,0 +1 @@
include $(sort $(wildcard $(BR2_EXTERNAL_PYTHON_PYBIND_PATH)/package/*/*.mk))

View File

@@ -0,0 +1,6 @@
config BR2_PACKAGE_PYTHON_PYBIND_EXAMPLE
bool "python-pybind-example"
depends on BR2_PACKAGE_PYTHON3
select BR2_PACKAGE_PYTHON_PYBIND
help
This test creates a cpp macro later used on target in python

View File

@@ -0,0 +1,16 @@
#include <pybind11/pybind11.h>
namespace py = pybind11;
int add (int i, int j) {
return i + j;
}
PYBIND11_MODULE (example, m) {
// optional module description
m.doc() = "pybind11 example plugin";
// test a module method
m.def("add", &add, "example::add adds two integer numbers");
// test a module attribute
py::object hello = py::cast("Hello World");
m.attr("says") = hello;
}

View File

@@ -0,0 +1,41 @@
################################################################################
#
# python-pybind-example
#
################################################################################
# this builds a C++ macro "add(a,b)"
# that we expose to host-python with a custom install
# and that the python test script will later use
PYTHON_PYBIND_EXAMPLE_DEPENDENCIES = python-pybind
PYTHON_PYBIND_EXAMPLE_PYBIND_INCLUDE = \
$(shell $(HOST_DIR)/bin/python3 -c 'import pybind11; print(pybind11.get_include())')
PYTHON_PYBIND_EXAMPLE_CXX_FLAGS = \
$(TARGET_CXXFLAGS) \
-Wall -shared -std=c++11 -fPIC \
-I$(PYTHON_PYBIND_EXAMPLE_PYBIND_INCLUDE) \
$(shell $(STAGING_DIR)/usr/bin/python3-config --includes --libs --ldflags)
# .so to be installed must have exact suffix
# otherwise import() in python will not work
HOST_LIB_BINARY_SUFFIX = \
$(shell $(STAGING_DIR)/usr/bin/python3-config --extension-suffix)
define PYTHON_PYBIND_EXAMPLE_BUILD_CMDS
if [ -z "$(PYTHON_PYBIND_EXAMPLE_PYBIND_INCLUDE)" ]; then \
echo "pybind11.get_include() returned empty"; \
exit 1; \
fi
$(TARGET_CXX) $(PYTHON_PYBIND_EXAMPLE_CXX_FLAGS) \
$(PYTHON_PYBIND_EXAMPLE_PKGDIR)/example.cpp \
-o $(@D)/example$(HOST_LIB_BINARY_SUFFIX)
endef
define PYTHON_PYBIND_EXAMPLE_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 755 $(@D)/example$(HOST_LIB_BINARY_SUFFIX) \
$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/example$(HOST_LIB_BINARY_SUFFIX)
endef
$(eval $(generic-package))

View File

@@ -0,0 +1,7 @@
#!/bin/sh
set -e
shift
for file in "$@"; do
cp -f "${file}" "${TARGET_DIR}/root/"
done

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

View File

@@ -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()

View File

@@ -0,0 +1 @@
import ftdi1 # noqa

View File

@@ -0,0 +1,3 @@
import iio
assert len(iio.scan_contexts()) == 1

View File

@@ -0,0 +1,3 @@
var assert = require('assert');
assert.strictEqual(1, 1);
console.log("Hello World");

View File

@@ -0,0 +1,7 @@
var assert = require('assert');
var lodash = require('lodash');
result = lodash.chunk(['a', 'b', 'c', 'd'], 2);
expected = [ [ 'a', 'b' ], [ 'c', 'd' ] ];
assert.deepStrictEqual(result, expected)

View File

@@ -0,0 +1,6 @@
#! /usr/bin/nu
def greet [name] {
["hello" $name]
}
greet "world"

View File

@@ -0,0 +1 @@
import aexpect

View File

@@ -0,0 +1,15 @@
from queue import Queue
from apscheduler.schedulers.background import BackgroundScheduler
queue = Queue()
def work():
queue.put("Ping!")
scheduler = BackgroundScheduler()
scheduler.add_job(work, "interval", seconds=1)
scheduler.start()
result = queue.get(timeout=3)
assert result == "Ping!"

View File

@@ -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)

View File

@@ -0,0 +1,11 @@
from asn1crypto import pem, x509
with open('/etc/ssl/certs/ISRG_Root_X2.pem', 'rb') as f:
der_bytes = f.read()
if pem.detect(der_bytes):
type_name, headers, der_bytes = pem.unarmor(der_bytes)
cert = x509.Certificate.load(der_bytes)
assert cert.subject.native["common_name"] == "ISRG Root X2"

View File

@@ -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

View File

@@ -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")

View File

@@ -0,0 +1 @@
import autobahn.wamp # noqa

View File

@@ -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()

View File

@@ -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',
}

View File

@@ -0,0 +1,6 @@
import bitstring
value = bitstring.BitArray("uint:12=42")
assert(value.hex == "02a")
assert(value.bin == "000000101010")
assert(value.uint == 42)

View File

@@ -0,0 +1,2 @@
import boto3
s3 = boto3.resource('s3')

View File

@@ -0,0 +1,3 @@
import botocore.session
session = botocore.session.get_session()
client = session.create_client('ec2', region_name="us-east-1")

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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()

View File

@@ -0,0 +1,8 @@
import cloudpickle
def fibonacci(n):
return n if n < 2 else fibonacci(n-1) + fibonacci(n-2)
serialized = cloudpickle.dumps(fibonacci)

View File

@@ -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)

View File

@@ -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

View File

@@ -0,0 +1,16 @@
# Inspired from https://construct.readthedocs.io/en/latest/intro.html#example
import construct
format = construct.Struct(
"signature" / construct.Const(b"BMP"),
"width" / construct.Int8ub,
"height" / construct.Int8ub,
"pixels" / construct.Array(construct.this.width * construct.this.height, construct.Byte),
)
a = format.build(dict(width=3,height=2,pixels=[7,8,9,11,12,13]))
assert(a == b'BMP\x03\x02\x07\x08\t\x0b\x0c\r')
b = format.parse(b'BMP\x03\x02\x07\x08\t\x0b\x0c\r')
assert(b.signature == b'BMP')
assert(b.width == 3)
assert(b.height == 2)
assert(b.pixels == [7, 8, 9, 11, 12, 13])

View File

@@ -0,0 +1,7 @@
from crc import Calculator, Crc8
expected = 0xBC
data = bytes([0, 1, 2, 3, 4, 5])
calculator = Calculator(Crc8.CCITT)
assert expected == calculator.checksum(data)

View File

@@ -0,0 +1,3 @@
from cryptography.fernet import Fernet
key = Fernet.generate_key()
f = Fernet(key)

View File

@@ -0,0 +1,45 @@
import asyncio
from dbus_fast.aio import MessageBus
from dbus_fast.service import ServiceInterface, method
import dbus_fast.introspection as intr
from dbus_fast 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.fast.sample'
obj_path = '/test/path'
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(obj_path, service_interface)
introspection = await bus2.introspect(bus_name, obj_path)
assert type(introspection) is intr.Node
obj = bus2.get_proxy_object(bus_name, obj_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())

View File

@@ -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())

View File

@@ -0,0 +1,11 @@
from dicttoxml2 import dicttoxml
payload: dict = {'mylist': ['foo', 'bar', 'baz'], 'mydict': {'foo': 'bar', 'baz': 1}, 'ok': True}
expected: bytes = b'<?xml version="1.0" encoding="UTF-8" ?><root><mylist type="list"><item type="str">' \
b'<![CDATA[foo]]></item><item type="str"><![CDATA[bar]]></item><item type="str"><![CDATA[baz]]>' \
b'</item></mylist><mydict type="dict"><foo type="str"><![CDATA[bar]]></foo><baz type="int">' \
b'<![CDATA[1]]></baz></mydict><ok type="bool"><![CDATA[True]]>' \
b'</ok></root>'
assert dicttoxml(payload, cdata=True) == expected

View File

@@ -0,0 +1,9 @@
from diskcache import Cache
cache = Cache()
cache['test'] = 123
assert cache['test'] == 123
del cache['test']
assert 'test' not in cache
cache.close()

View File

@@ -0,0 +1,4 @@
import distro
assert(distro.name() == 'Buildroot')
assert(distro.id() == 'buildroot')

View File

@@ -0,0 +1 @@
import django # noqa: F401

View File

@@ -0,0 +1,12 @@
import docker
client = docker.from_env()
info = client.info()
images = client.images.list()
assert len(images) > 0
print('Version:', info['ServerVersion'])
print('Images:')
for i in images:
print(i.tags[0])

View File

@@ -0,0 +1 @@
import dtschema

View File

@@ -0,0 +1,11 @@
import evdev
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
e = evdev.events.InputEvent(1036996631, 984417, evdev.ecodes.EV_KEY, evdev.ecodes.KEY_A, 2)
k = evdev.events.KeyEvent(e)
assert(k.keystate == evdev.events.KeyEvent.key_hold)
assert(k.event == e)
assert(k.scancode == evdev.ecodes.KEY_A)
assert(k.keycode == 'KEY_A')
assert(len(devices) > 0)

View File

@@ -0,0 +1,6 @@
import farama_notifications
NOTIFICATION_ID = "test_event_occurrence"
NOTIFICATION_MESSAGE = "A test event has occurred in Buildroot environment!"
farama_notifications.notifications[NOTIFICATION_ID] = NOTIFICATION_MESSAGE

View File

@@ -0,0 +1,8 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}

View File

@@ -0,0 +1,7 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'

View File

@@ -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!'

View File

@@ -0,0 +1 @@
from git import * # noqa

View File

@@ -0,0 +1 @@
from gitdb import * # noqa

View File

@@ -0,0 +1,24 @@
import gnupg
gpg = gnupg.GPG(verbose=True)
plain_data = "Some plain text data"
good_passphrase = "Good Passphrase"
# Test Encrypt
result = gpg.encrypt(plain_data, None, passphrase=good_passphrase, symmetric=True)
assert(result.returncode == 0)
enc_data = str(result)
assert(enc_data != plain_data)
# Test Good Decrypt
result = gpg.decrypt(enc_data, passphrase=good_passphrase)
assert(result.returncode == 0)
dec_data = str(result)
assert(dec_data == plain_data)
# Test Bad Decrypt
result = gpg.decrypt(enc_data, passphrase='A Wrong Passphrase')
assert(result.returncode != 0)
dec_data = str(result)
assert(dec_data != plain_data)

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env python3
"""A simple test that uses python-gobject to find the path of sh."""
from gi.repository import GLib
def main():
# In Glib >= 2.88, GLib.unix_signal_add has been moved to a
# separate platform-specific library. This break backward
# compatibility from GLib-2.0.
# A workaround has been applied to pygobject >= 3.55.3
# https://gitlab.gnome.org/GNOME/pygobject/-/commit/74e4e0f40a66436a55c72d4a6e6058c1f91a7310
unix_signal_add = GLib.unix_signal_add_full # noqa
sh_path = GLib.find_program_in_path('sh')
if sh_path == "/bin/sh":
return True
return False
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,5 @@
from gpiozero import pi_info
piBoardInfo = pi_info('a020d3') # 3B+
assert piBoardInfo.model == '3B+'

View File

@@ -0,0 +1,8 @@
import gymnasium as gym
env = gym.make("CartPole-v1")
observation, info = env.reset()
random_action = env.action_space.sample()
next_observation, reward, terminated, truncated, info = env.step(random_action)
env.close()

View File

@@ -0,0 +1,3 @@
import hid
hid.enumerate()

View File

@@ -0,0 +1,22 @@
import hashlib
from binascii import hexlify, unhexlify
from hkdf import Hkdf, hkdf_expand, hkdf_extract
salt = b"ThisIsTheSalt."
key_in = b"ThisIsTheSecretKey"
key_info = b"KeyInfo1"
key_len = 16
expected_key = unhexlify(b"b49d6cc9065b72f3a0859377d8bb7299")
prk = hkdf_extract(salt, input_key_material=key_in, hash=hashlib.sha512)
key1 = hkdf_expand(prk, info=key_info, length=key_len)
print("key1:", hexlify(key1))
assert key1 == expected_key
kdf = Hkdf(salt, input_key_material=key_in, hash=hashlib.sha512)
key2 = kdf.expand(info=key_info, length=key_len)
print("key2:", hexlify(key2))
assert key2 == expected_key

View File

@@ -0,0 +1,6 @@
import humanfriendly as hf
h_size = "16MiB"
b_size = hf.parse_size(h_size)
assert b_size == 16*1024*1024

View File

@@ -0,0 +1,40 @@
#! /usr/bin/env python3
from hwdata import PCI, PNP, USB
# Test PCI IDs
pci_vendor_id = '1af4'
pci_device_id = '1003'
pci = PCI()
pci_vendor = pci.get_vendor(pci_vendor_id)
print("PCI Vendor: %s" % pci_vendor)
assert (pci_vendor == "Red Hat, Inc.")
pci_device = pci.get_device(pci_vendor_id, pci_device_id)
print("PCI Device: %s" % pci_device)
assert (pci_device == "Virtio console")
# Test USB IDs
usb_vendor_id = '1d6b'
usb_device_id = '0001'
usb = USB()
usb_vendor = usb.get_vendor(usb_vendor_id)
print("USB Vendor: %s" % usb_vendor)
assert (usb_vendor == "Linux Foundation")
usb_device = usb.get_device(usb_vendor_id, usb_device_id)
print("USB Device: %s" % usb_device)
assert (usb_device == "1.1 root hub")
# Test PNP IDs
pnp_id = 'RHT'
pnp = PNP()
pnp_vendor = pnp.get_vendor(pnp_id)
print("PNP Vendor: %s" % pnp_vendor)
assert (pnp_vendor == "Red Hat, Inc.")

View File

@@ -0,0 +1,3 @@
import incremental
v = incremental.Version("package", 1, 2, 3, release_candidate=4)
assert(str(v) == "[package, version 1.2.3rc4]")

View File

@@ -0,0 +1 @@
import iptc

View File

@@ -0,0 +1,4 @@
import jmespath
expression = jmespath.compile('foo.bar')
res = expression.search({'foo': {'bar': 'baz'}})
assert res == "baz", "expression.search failed"

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