cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

info_usernet.py (992B)


      1# Test for the hmp command "info usernet"
      2#
      3# Copyright (c) 2021 Red Hat, Inc.
      4#
      5# Author:
      6#  Cleber Rosa <crosa@redhat.com>
      7#
      8# This work is licensed under the terms of the GNU GPL, version 2 or
      9# later.  See the COPYING file in the top-level directory.
     10
     11from avocado_qemu import Test
     12
     13from qemu.utils import get_info_usernet_hostfwd_port
     14
     15
     16class InfoUsernet(Test):
     17
     18    def test_hostfwd(self):
     19        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22')
     20        self.vm.launch()
     21        res = self.vm.command('human-monitor-command',
     22                              command_line='info usernet')
     23        port = get_info_usernet_hostfwd_port(res)
     24        self.assertIsNotNone(port,
     25                             ('"info usernet" output content does not seem to '
     26                              'contain the redirected port'))
     27        self.assertGreater(port, 0,
     28                           ('Found a redirected port that is not greater than'
     29                            ' zero'))