<commit_before>#!/bin/bash
# bash is required by declare -A
# @file
# @brief
#
# @author  <NAME>
# @date    30.07.2013
#

# ATML == arch + template, i.e. x86/debug
ATML="$1"
SIM_ARG="$2"
shift 2
OTHER_ARGS=$@

if [ $CONTINIOUS_RUN_TIMEOUT ]; then
	TIMEOUT=$CONTINIOUS_RUN_TIMEOUT
else
	TIMEOUT=45
fi

EMKERNEL=./build/base/bin/embox
OUTPUT_FILE=./cont.out

# qemu refuses to write if run with -serial stdio. So we buffer to file,
# cat it, and analyze
AUTOQEMU_KVM_ARG=
AUTOQEMU_NOGRAPHIC_ARG="-serial file:${OUTPUT_FILE} -display none"
RUN_QEMU="./scripts/qemu/auto_qemu $SIM_ARG"

USERMODE_START_OUTPUT=$OUTPUT_FILE

declare -A atml2run
atml2run=(
	['arm/qemu']=default_run
	['x86/nonvga_debug']=default_run
	['x86/smp']=default_run
	['x86/test_fs']="$(dirname $0)/fs/run.sh $ATML"
	['x86/test_net']="$(dirname $0)/net/run.sh $ATML"
	['sparc/debug']=default_run
	['mips/debug']=default_run
	['ppc/debug']=default_run
	['microblaze/petalogix']=default_run
	['usermode86/debug']=default_run
	['generic/qemu']=default_run
	['generic/qemu_bg']=run_bg_wrapper
	['generic/qemu_bg_kill']=kill_bg_wrapper
	['generic/fail']=false
)

sim_bg=
run_bg() {
	declare -A atml2sim
	#"sparc/qemu" not supported due qemu bug
	atml2sim=(
		['arm/qemu']="$RUN_QEMU"
		['x86/nonvga_debug']="$RUN_QEMU"
		['x86/smp']="$RUN_QEMU -smp 2"
		['sparc/debug']="$(dirname $0)/tsim_run.sh $OUTPUT_FILE $SIM_ARG $EMKERNEL"
		['mips/debug']="$RUN_QEMU"
		['ppc/debug']="$RUN_QEMU"
		['microblaze/petalogix']="$RUN_QEMU"
		['usermode86/debug']="$(dirname $0)/../usermode_start.sh"
		['generic/qemu_bg']="$RUN_QEMU"
		['generic/qemu']="$RUN_QEMU"
	)

	sudo PATH=$PATH \
		AUTOQEMU_KVM_ARG="$AUTOQEMU_KVM_ARG" \
		AUTOQEMU_NOGRAPHIC_ARG="$AUTOQEMU_NOGRAPHIC_ARG" \
		AUTOQEMU_NICS_CONFIG="$AUTOQEMU_NICS_CONFIG" \
		USERMODE_START_OUTPUT="$USERMODE_START_OUTPUT" \
		${atml2sim[$ATML]} &
	sim_bg=$!
}

run_check() {

	ret=1
	for success_pattern in 'embox>' '[a-z]\+@embox'; do
		if grep "$success_pattern" $OUTPUT_FILE &>/dev/null ; then
			ret=0
		fi
	done
	for fail_pattern in "fail" "assert"; do<commit_msg>CI: run.sh refactoring a little<commit_after>#!/bin/bash
# bash is required by declare -A
# @file
# @brief
#
# @author  <NAME>
# @date    30.07.2013
#

# ATML == arch + template, i.e. x86/debug
ATML="$1"
SIM_ARG="$2"
shift 2
OTHER_ARGS=$@

if [ $CONTINIOUS_RUN_TIMEOUT ]; then
	TIMEOUT=$CONTINIOUS_RUN_TIMEOUT
else
	TIMEOUT=45
fi

EMKERNEL=./build/base/bin/embox
OUTPUT_FILE=./cont.out

# qemu refuses to write if run with -serial stdio. So we buffer to file,
# cat it, and analyze
AUTOQEMU_KVM_ARG=
AUTOQEMU_NOGRAPHIC_ARG="-serial file:${OUTPUT_FILE} -display none"
RUN_QEMU="./scripts/qemu/auto_qemu $SIM_ARG"

USERMODE_START_OUTPUT=$OUTPUT_FILE

declare -A atml2run
atml2run=(
	['arm/qemu']=default_run
	['x86/nonvga_debug']=default_run
	['x86/smp']=default_run
	['x86/test_fs']="$(dirname $0)/fs/run.sh $ATML"
	['x86/test_net']="$(dirname $0)/net/run.sh $ATML"
	['sparc/debug']=default_run
	['mips/debug']=default_run
	['ppc/debug']=default_run
	['microblaze/petalogix']=default_run
	['usermode86/debug']=default_run
	['generic/qemu']=default_run
	['generic/qemu_bg']=run_bg_wrapper
	['generic/qemu_bg_kill']=kill_bg_wrapper
	['generic/fail']=false
)

sim_bg=
run_bg() {
	declare -A atml2sim
	#"sparc/qemu" not supported due qemu bug
	atml2sim=(
		['x86/smp']="$RUN_QEMU -smp 2"
		['sparc/debug']="$(dirname $0)/tsim_run.sh $OUTPUT_FILE $SIM_ARG $EMKERNEL"
		['usermode86/debug']="$(dirname $0)/../usermode_start.sh"
	)

	run_cmd=${atml2sim[$ATML]}
	if [ -z "$run_cmd" ]; then
		run_cmd="$RUN_QEMU"
	fi

	sudo PATH=$PATH \
		AUTOQEMU_KVM_ARG="$AUTOQEMU_KVM_ARG" \
		AUTOQEMU_NOGRAPHIC_ARG="$AUTOQEMU_NOGRAPHIC_ARG" \
		AUTOQEMU_NICS_CONFIG="$AUTOQEMU_NICS_CONFIG" \
		USERMODE_START_OUTPUT="$USERMODE_START_OUTPUT" \
		$run_cmd &
	sim_bg=$!
}

run_check() {

	ret=1
	for success_pattern in 'embox>' '[a-z]\+@embox'; do
		if grep "$success_pattern" $OUTPUT_FILE &>/dev/null ; then
			ret=0
		fi
	done
	for fail_pattern in "fail" "assert"; do
{'fraction_non_alphanumeric': 0.17562189054726368, 'fraction_numerical': 0.020895522388059702, 'mean_word_length': 5.42332268370607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2818879', 'n_tokens_mistral': 1867, 'n_tokens_neox': 1777, 'n_words': 283}