All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: Marius Vlad <marius.c.vlad@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 2/3] tests/drv_module_reload_basic: Convert sh script to C version.
Date: Fri, 21 Oct 2016 12:39:22 +0300	[thread overview]
Message-ID: <8ead15bf-e586-2a53-2176-7034afb8376b@intel.com> (raw)
In-Reply-To: <20161020193649.11701-3-marius.c.vlad@intel.com>



On 10/20/2016 10:36 PM, Marius Vlad wrote:
> Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
> ---
>   tests/Makefile.sources          |   2 +-
>   tests/drv_module_reload_basic   |  97 -----------------------
>   tests/drv_module_reload_basic.c | 166 ++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 167 insertions(+), 98 deletions(-)
>   delete mode 100755 tests/drv_module_reload_basic
>   create mode 100644 tests/drv_module_reload_basic.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 6d081c3..c35ea11 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -211,6 +211,7 @@ TESTS_progs = \
>   	kms_pwrite_crc \
>   	kms_sink_crc_basic \
>   	prime_udl \
> +	drv_module_reload_basic \
>   	$(NULL)
>   
>   # IMPORTANT: The ZZ_ tests need to be run last!
> @@ -221,7 +222,6 @@ TESTS_scripts_M = \
>   TESTS_scripts = \
>   	debugfs_emon_crash \
>   	drv_debugfs_reader \
> -	drv_module_reload_basic \
>   	kms_sysfs_edid_timing \
>   	sysfs_l3_parity \
>   	test_rte_check \
> diff --git a/tests/drv_module_reload_basic b/tests/drv_module_reload_basic
> deleted file mode 100755
> index a8d628d..0000000
> --- a/tests/drv_module_reload_basic
> +++ /dev/null
> @@ -1,97 +0,0 @@
> -#!/bin/bash
> -#
> -# Testcase: Reload the drm module
> -#
> -# ... we've broken this way too often :(
> -#
> -
> -SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
> -. $SOURCE_DIR/drm_lib.sh
> -
> -# no other drm service should be running, so we can just unbind
> -
> -# return 0 if module by name $1 is loaded according to lsmod
> -function mod_loaded()
> -{
> -	lsmod | grep -w "^$1" &> /dev/null
> -}
> -
> -function reload() {
> -	local snd_hda_intel_unloaded
> -
> -	echo Reloading i915.ko with $*
> -
> -	# we must kick away fbcon (but only fbcon)
> -	for vtcon in /sys/class/vtconsole/vtcon*/ ; do
> -		if grep "frame buffer device" $vtcon/name > /dev/null ; then
> -			echo unbinding $vtcon: `cat $vtcon/name`
> -			echo 0 > $vtcon/bind
> -		fi
> -	done
> -
> -	# The sound driver uses our power well
> -	pkill alsactl
> -	snd_hda_intel_unloaded=0
> -	if mod_loaded snd_hda_intel; then
> -		rmmod snd_hda_intel && snd_hda_intel_unloaded=1
> -	fi
> -
> -	# gen5 only
> -	if mod_loaded intel_ips; then
> -		rmmod intel_ips
> -	fi
> -	rmmod i915 || return $IGT_EXIT_SKIP
> -	#ignore errors in intel-gtt, often built-in
> -	rmmod intel-gtt &> /dev/null
> -	# drm may be used by other devices (nouveau, radeon, udl, etc)
> -	rmmod drm_kms_helper &> /dev/null
> -	rmmod drm &> /dev/null
> -
> -	if mod_loaded i915; then
> -		echo WARNING: i915.ko still loaded!
> -		return $IGT_EXIT_FAILURE
> -	else
> -		echo module successfully unloaded
> -	fi
> -
> -	modprobe i915 $*
> -
> -	if [ -f /sys/class/vtconsole/vtcon1/bind ]; then
> -		echo 1 > /sys/class/vtconsole/vtcon1/bind
> -	fi
> -
> -	modprobe -q snd_hda_intel || return $snd_hda_intel_unloaded
> -}
> -
> -function finish_load() {
> -	# does the device exist?
> -	if $SOURCE_DIR/gem_alive > /dev/null ; then
> -		echo "module successfully loaded again"
> -	else
> -		echo "failed to reload module successfully"
> -		return $IGT_EXIT_FAILURE
> -	fi
> -
> -	# then try to run something
> -	if ! $SOURCE_DIR/gem_exec_store > /dev/null ; then
> -		echo "failed to execute a simple batch after reload"
> -		return $IGT_EXIT_FAILURE
> -	fi
> -
> -	return $IGT_EXIT_SUCCESS
> -}
> -
> -hda_dynamic_debug_enable

I don't see the equivalent of hda_dynamic_debug_enable in the C version.


> -
> -reload || exit $?
> -finish_load || exit $?
> -
> -# Repeat the module reload trying to to generate faults
> -for i in $(seq 1 4); do
> -	reload inject_load_failure=$i
> -done
> -
> -reload || exit $?
> -finish_load
> -
> -exit $?
> diff --git a/tests/drv_module_reload_basic.c b/tests/drv_module_reload_basic.c
> new file mode 100644
> index 0000000..d36afde
> --- /dev/null
> +++ b/tests/drv_module_reload_basic.c
> @@ -0,0 +1,166 @@
> +/*
> + * Copyright © 2016 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +#include "igt.h"
> +#include "igt_debugfs.h"
> +#include "igt_aux.h"
> +#include "igt_sysfs.h"
> +#include "igt_core.h"
> +
> +#include <dirent.h>
> +#include <sys/utsname.h>
> +#include <linux/limits.h>
> +#include <signal.h>
> +#include <libgen.h>
> +
> +#include <libkmod.h>
> +#include <proc/readproc.h>
> +
> +static const char *tests[] = {
> +	"gem_alive", "gem_exec_store"
> +};
> +
> +static int
> +reload(const char *opts_i915)
> +{
> +	kick_fbcon(0);
> +
> +	if (opts_i915)
> +		igt_info("Reloading i915 with %s\n\n", opts_i915);
> +
> +	if (igt_lsmod_has_module("snd_hda_intel")) {
> +		if (igt_pkill(SIGTERM, "alsactl") == -1) {
> +			return IGT_EXIT_FAILURE;
> +		}
> +		if (igt_rmmod("snd_hda_intel", false) == -1)
> +			return IGT_EXIT_FAILURE;
> +	}
> +
> +	/* gen5 */
> +	if (igt_lsmod_has_module("intel_ips")) {
> +		igt_rmmod("intel_ips", false);
> +	}
> +
> +	if (igt_rmmod("i915", false) == -1) {
> +		return IGT_EXIT_SKIP;
> +	}
> +
> +	igt_info("i915.ko has been unloaded!\n");
> +
> +	if (igt_lsmod_has_module("intel-gtt")) {
> +		igt_rmmod("intel-gtt", false);
> +	}
> +
> +	igt_rmmod("drm_kms_helper", false);
> +	igt_rmmod("drm", false);
> +
> +	if (igt_lsmod_has_module("i915")) {
> +		igt_info("WARNING: i915.ko still loaded!\n");
> +		return IGT_EXIT_FAILURE;
> +	} else {
> +		igt_info("module successfully unloaded\n");
> +	}
> +
> +	/* we do not have automatic loading of dependencies */
> +	igt_insmod("drm", NULL);
> +	igt_insmod("drm_kms_helper", NULL);
> +
> +	if (igt_insmod("i915", opts_i915) == -1) {
> +		igt_info("Could not load i915\n");
> +		return IGT_EXIT_FAILURE;
> +	}
> +
> +	kick_fbcon(1);
> +
> +	if (igt_insmod("snd_hda_intel", NULL) == -1)
> +		return IGT_EXIT_FAILURE;
> +
> +	return IGT_EXIT_SUCCESS;
> +}
> +
> +static void
> +igt_execv(char **argv)
> +{
> +	igt_fork(child, 1) {
> +		if (execv(argv[0], argv) < 0) {
> +			igt_info("Failed to exec %s\n",
> +					argv[0]);
> +			exit(IGT_EXIT_FAILURE);
> +		}
> +	}
> +	igt_waitchildren();
> +}
> +
> +static void
> +finish_load(char *dirname)
> +{
> +	char buf[PATH_MAX];
> +	char *__argv[2] = { buf, NULL };
> +
> +	memset(buf, 0, PATH_MAX);
> +	snprintf(buf, sizeof(buf), "%s/%s", dirname, tests[0]);
> +
> +	igt_execv(__argv);
> +
> +	memset(buf, 0, sizeof(buf));
> +	snprintf(buf, sizeof(buf), "%s/%s", dirname, tests[1]);
> +
> +	igt_execv(__argv);
> +}
> +
> +int main(int argc, char *argv[])
> +{
> +	int i, err;
> +	char buf[64];
> +	char *prg, *dir;
> +
> +	prg = strdup(argv[0]);
> +	igt_subtest_init_parse_opts(&argc, argv, "", NULL,
> +				    NULL, NULL, NULL);
> +
> +
> +	igt_subtest("basic-reload") {
> +		if ((err = reload(NULL)))
> +			igt_fail(err);
> +	}
> +
> +	igt_subtest("basic-exec") {
> +		dir = dirname(prg);
> +		finish_load(dir);
> +	}
> +
> +	igt_subtest("basic-reload-inject") {
> +		for (i = 0; i < 4; i++) {
> +			memset(buf, 0, sizeof(buf));
> +			snprintf(buf, sizeof(buf), "inject_load_failure=%d", i);
> +			reload(buf);
> +		}
> +	}
> +
> +	igt_subtest("basic-reload-final")
> +		if ((err = reload(NULL)))
> +			igt_fail(err);
> +

An accompanying change to tests/intel-ci/fast-feedback.testlist in the 
same commit required.


-- 
Petri Latvala


> +	free(prg);
> +
> +	igt_exit();
> +}

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-10-21  9:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 19:36 [PATCH i-g-t 0/3] Convert sh scripts to C variants Marius Vlad
2016-10-20 19:36 ` [PATCH i-g-t 1/3] lib/{igt_sysfs, igt_aux}: Make available to other users kick_fbcon() (unbind_fbcon()), and added helpers to igt_aux Marius Vlad
2016-10-20 20:09   ` Chris Wilson
2016-10-24 18:08     ` Marius Vlad
2016-10-24  8:40   ` Daniel Vetter
2016-10-26 21:02     ` Marius Vlad
2016-10-27  6:40       ` Daniel Vetter
2016-10-20 19:36 ` [PATCH i-g-t 2/3] tests/drv_module_reload_basic: Convert sh script to C version Marius Vlad
2016-10-20 19:52   ` Chris Wilson
2016-10-24 18:05     ` Marius Vlad
2016-10-24 20:34       ` Chris Wilson
2016-10-21  9:39   ` Petri Latvala [this message]
2016-10-24 18:06     ` Marius Vlad
2016-10-20 19:36 ` [PATCH i-g-t 3/3] tests/kms_sysfs_edid_timing: " Marius Vlad
2016-10-20 19:58   ` Chris Wilson
2016-10-20 21:00 ` [PATCH i-g-t 0/3] Convert sh scripts to C variants Jani Nikula
2016-10-21  7:38   ` Joonas Lahtinen
2016-10-24  8:46     ` Daniel Vetter
2016-10-24  8:49       ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ead15bf-e586-2a53-2176-7034afb8376b@intel.com \
    --to=petri.latvala@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=marius.c.vlad@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.