<commit_before>#! /usr/bin/python

import sys
import os

includeos_src = os.environ.get('INCLUDEOS_SRC',
                               os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
sys.path.insert(0,includeos_src + "/test")

import vmrunner

vm = vmrunner.vms[0];

def check_hex(line):
  my_hex = line.split(":")[1].strip()
  res = int(my_hex, 16)
  return res == 100;

format_string_size = None

def set_format_string_size(line):
  global format_string_size

  print "Received format string: ", line
  format_string_size = int(line.split(":")[1].strip())

def check_truncation(line):
  assert(format_string_size)

  print "Received truncated string: ", line, "of size", len(line), "(format size * ", len(line)/format_string_size,")"
  assert(len(line) <= format_string_size * 2)
  assert(line.strip().split(" ")[-1] != "END")

vm.on_output("I can print hex", check_hex)
vm.on_output("Format", set_format_string_size)
vm.on_output("truncate", check_truncation)

vm.cmake().boot(20)<commit_msg>test: kprint test now cleans after run<commit_after>#! /usr/bin/python

import sys
import os

includeos_src = os.environ.get('INCLUDEOS_SRC',
                               os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0])
sys.path.insert(0,includeos_src + "/test")

import vmrunner

vm = vmrunner.vms[0];

def check_hex(line):
  my_hex = line.split(":")[1].strip()
  res = int(my_hex, 16)
  return res == 100;

format_string_size = None

def set_format_string_size(line):
  global format_string_size

  print "Received format string: ", line
  format_string_size = int(line.split(":")[1].strip())

def check_truncation(line):
  assert(format_string_size)

  print "Received truncated string: ", line, "of size", len(line), "(format size * ", len(line)/format_string_size,")"
  assert(len(line) <= format_string_size * 2)
  assert(line.strip().split(" ")[-1] != "END")

vm.on_output("I can print hex", check_hex)
vm.on_output("Format", set_format_string_size)
vm.on_output("truncate", check_truncation)

# Build, run and clean
vm.cmake().boot().clean()
{'fraction_non_alphanumeric': 0.16619718309859155, 'fraction_numerical': 0.012206572769953052, 'mean_word_length': 4.806539509536785, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, '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': '4877579', 'n_tokens_mistral': 788, 'n_tokens_neox': 756, 'n_words': 147}