Skip to content

Ktest2 #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ steps:
- label: "build amd64 in docker"
key: make_docker
command: "make docker"
artifact_paths:
- "initramfs.gz"
agents:
image: family/core-ubuntu-2204
provider: gcp
Expand Down Expand Up @@ -29,6 +31,7 @@ steps:
key: test
command: "./.buildkite/runtest.sh"
depends_on:
- make_docker
- make_centos7
agents:
image: family/core-ubuntu-2204
Expand Down
7 changes: 7 additions & 0 deletions .buildkite/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ if [ -z "${BUILDKITE}" ]; then
exit 1
fi

download initramfs.gz .
download quark-test .
chmod +x quark-test

echo updating packages...
sudo apt-get -qq update -y
echo installing packages...
sudo apt-get -qq install -y --no-install-recommends qemu-system-x86 > /dev/null

sudo ./quark-test
./krun.sh initramfs.gz kernel-images/linux-4.18.0-553.el8_10.x86_64 quark-test
exit $?
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ DOCKER_RUN_ARGS=$(QDOCKER) \

docker: docker-image clean-all
$(call msg,DOCKER-RUN,Dockerfile)
$(Q)$(DOCKER) run $(DOCKER_RUN_ARGS) /bin/bash -c "make -C $(PWD)"
$(Q)$(DOCKER) run \
$(DOCKER_RUN_ARGS) \
/bin/bash -c "make -C $(PWD) all initramfs.gz"

docker-cross-arm64: clean-all docker-image manpages.h
$(call msg,DOCKER-RUN,Dockerfile)
Expand Down
28 changes: 25 additions & 3 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sys/reboot.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/utsname.h>
#include <sys/wait.h>

static void
Expand All @@ -27,11 +28,31 @@ powerdown(void)
}
}

static void
display_banner(char *argv[])
{
struct utsname uts;
char **pp;

if (uname(&uts) == -1)
warn("uname");
else {
putchar('`');
for (pp = argv; *pp != 0; pp++) {
if (pp != argv)
putchar(' ');
printf("%s", *pp);
}
putchar('`');
printf(" on %s %s\n", uts.release, uts.machine);
}
}

int
main(int argc, char *argv[])
{
pid_t pid;
int status;
pid_t pid;
int status;

/*
* Cut the kernel some slack until it is in a good shape, I see TSC
Expand All @@ -55,7 +76,6 @@ main(int argc, char *argv[])

/* child */
if (pid == 0) {

if (mkdir("/proc", 0666) != 0)
err(1, "mkdir /proc");
if (mkdir("/sys", 0666) != 0)
Expand All @@ -76,6 +96,8 @@ main(int argc, char *argv[])
}
}

display_banner(argv);

return (execv(argv[0], argv));
}

Expand Down
Binary file added kernel-images/linux-4.18.0-553.el8_10.x86_64
Binary file not shown.
55 changes: 55 additions & 0 deletions krun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

Script=${0##*/}

function usage
{
echo "usage: $Script initramfs_path kernel_path cmd_line" 1>&2
exit 1
}

if [ $# -lt 3 ]; then
usage
fi

initramfs="$1"
kernel="$2"
shift 2
cmdline="$*"

function qemu {
case "$(file -b "$kernel" | awk '{print $3}')" in
x86)
qemu-system-x86_64 \
-initrd "$initramfs" \
-kernel "$kernel" \
-nographic \
--append "console=ttyS0 quiet TERM=dumb $cmdline"
;;
ARM64)
qemu-system-aarch64 \
-machine virt \
-cpu cortex-a57 \
-initrd "$initramfs" \
-kernel "$kernel" \
-nographic \
--append "console=ttyAMA0 quiet $cmdline"
;;
*)
echo unknown kernel image arch 1>&2; exit 1;;
esac
}

exitcode=1
while read -r line
do
echo "$line"
if grep -q '^quark-test exited with ' <<< "$line"; then
line="$(tr -d '\r' <<< "$line")"
exitcode="$(awk '{print $4}' <<< "$line")"
fi
done < <(qemu)

echo exited with "$exitcode"

exit $((exitcode))
14 changes: 14 additions & 0 deletions ktestall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

truncate -s 0 result

for k in /d/e/ebpf/kernel-images/debian/x86_64/* /d/kernel-images/*
do
kname="$(basename "$k")"
echo testing "$kname"
if ./ktest.sh initramfs.gz "$k"; then
printf "%s: ok\n" "$kname" >> result
else
printf "%s: fail\n" "$kname" >> result
fi
done