[PATCH btbridge 3/3] Initial set of test.

Daniel Axtens dja at axtens.net
Fri Jan 15 11:15:19 AEDT 2016


Hi Cyril,

> Very simple tests which can hopefully be extended in the future.

Yay for tests!

A little bit of explanation of the various bits would have been nice.

> diff --git a/.build.sh b/.build.sh
> index 79b0b5c..e762a85 100755
> --- a/.build.sh
> +++ b/.build.sh
> @@ -1,9 +1,11 @@
>  #!/bin/bash
> +set -evx
Did you intend this line to make it past debugging and into your commit?
>  
>  Dockerfile=$(cat << EOF
>  FROM ubuntu:15.10
>  RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get upgrade -yy
>  RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -yy make gcc libsystemd-dev libc6-dev pkg-config
> +RUN mkdir /var/run/dbus
>  RUN groupadd -g ${GROUPS} ${USER} && useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
>  USER ${USER}
>  ENV HOME ${HOME}
> @@ -14,6 +16,9 @@ EOF
>  docker pull ubuntu:15.10
>  docker build -t temp - <<< "${Dockerfile}"
>  
> +sudo cp .org.openbmc.HostIpmi.conf.test /etc/dbus-1/system.d/org.openbmc.HostIpmi.conf
> +sudo service dbus restart
> +
>  gcc --version
>  
>  mkdir -p linux
> @@ -21,3 +26,7 @@ wget https://raw.githubusercontent.com/openbmc/linux/dev-4.3/include/uapi/linux/
>  
>  docker run --cap-add=sys_admin --net=host --rm=true --user="${USER}" \
>   -w "${PWD}" -v "${HOME}":"${HOME}" -t temp make KERNEL_HEADERS=$PWD
> +
> +docker run --cap-add=sys_admin --net=host -v /var/run/dbus:/var/run/dbus --rm=true --user="${USER}" \
> + -w "${PWD}" -v "${HOME}":"${HOME}" -t temp ./run_tests.sh
> +
> diff --git a/.org.openbmc.HostIpmi.conf.test b/.org.openbmc.HostIpmi.conf.test
> new file mode 100644
> index 0000000..196945f
> --- /dev/null
> +++ b/.org.openbmc.HostIpmi.conf.test
> @@ -0,0 +1,20 @@
> +<?xml version="1.0"?> <!--*-nxml-*-->
> +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration
> +1.0//EN"
> +        "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
Is it just me or is this wrapped oddly?

> +
> +<!--
> +	This file is need to run openbmc bt bridge daemon.
> +	Place this file in /etc/dbus-1/system.d/
> +-->
> +
> +<busconfig>
> +
> +        <policy context="default">
> +                <allow own="org.openbmc.HostIpmi"/>
> +                <allow send_destination="org.openbmc.HostIpmi"/>
> +                <allow receive_sender="org.openbmc.HostIpmi"/>
> +        </policy>
> +
> +</busconfig>
> +

> diff --git a/bt-host.c b/bt-host.c
> new file mode 100644
> index 0000000..65bf6bb
> --- /dev/null
> +++ b/bt-host.c
> @@ -0,0 +1,235 @@
> +#define _GNU_SOURCE
> +#include <dlfcn.h>
> +#include <errno.h>
> +#include <poll.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <sys/types.h>          /* See NOTES */
                                   ^-- did you copy this from a manpage?
                                   I can't find a NOTES section here...
> +#include <sys/socket.h>
> +
> +#include <linux/bt-host.h>
> +
> +struct bttest_data {
> +	int status;
> +	const char msg[64];
> +};
> +
> +static int bt_host_fd;
> +static int timer_fd;
> +
> +static int stop;
> +static int sent_id = -1;
> +static int recv_id;
> +
> +/*
> + * btbridged doesn't care about the message EXCEPT the first byte must be
> + * correct.
> + * The first byte is the size not including the length byte its self.
> + * A len less than 4 will constitute an invalid message according to the BT
> + * protocol, btbridged will care.
> + */
> +static struct bttest_data data[] = {
Can this be const?

> +#define BTTEST_NUM (sizeof(data)/sizeof(struct bttest_data))
Do we have ccan here? Can we use ARRAY_SIZE?

Once again, thanks for writing tests!

Regards,
Daniel


More information about the openbmc mailing list