Skip to content

Commit

Permalink
Fixed duplicates in U.EXE, added simple test (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
excitoon authored May 14, 2024
1 parent 3a86f67 commit 4842bc7
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 61 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dockerignore
Dockerfile
docker-compose.yml
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ RUN python3 -m tools.build
RUN unzip UltimaVI-ru.zip
RUN rm UltimaVI-ru.zip
RUN mv UltimaVI-ru/* .
RUN rm -rf UltimaVI-ru
RUN rmdir UltimaVI-ru

COPY tools/RK.COM .
COPY tools/RK211.COM .
COPY tools/RUSSIAN.RK .
COPY tools/8X16.RK .

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:

test:
build: .
pull_policy: build
environment:
- DISPLAY
volumes:
Expand Down
24 changes: 24 additions & 0 deletions patches/bad-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@
38281
]
},
{
"source": "U.EXE",
"offset": 92153,
"bad-references": [
109972
]
},
{
"source": "U.EXE",
"offset": 92158,
"bad-references": [
109976,
109980,
109984
]
},
{
"source": "U.EXE",
"offset": 92318,
"bad-references": [
73438,
73440
]
},
{
"source": "U.EXE",
"offset": 94748,
Expand Down
Binary file added screenshots/U/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/U/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion testbox
Submodule testbox updated 1 files
+8 −2 testbox/__init__.py
45 changes: 45 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
import shutil
import time
import unittest

import testbox


class TestCase(unittest.TestCase):
def __init__(self, *args, **kwargs):
Expand All @@ -10,3 +14,44 @@ def __init__(self, *args, **kwargs):
@property
def script_path(self):
return self.__script_path


class InstalledTestCase(unittest.TestCase):
def setUp(self):
configuration = {
'cpu': {
'cycles': 'max',
},
'render': {
'scaler': 'normal2x forced',
},
}

with testbox.TestBox(
[
'-c', 'MOUNT C: .',
'-c', 'C:',
'INSTALL.EXE',
],
configuration,
timeout_error=AssertionError,
) as box:
for keys in (
'H', # Hard disk.
'C', # Drive C:.
'5', # VGA.
'Y', # Mouse.
'1', # Adlib.
'\r', # Default port.
'Y', # Everything is correct.
):
box.send_keys(keys)
time.sleep(0.1)

box.wait_image('screenshots/INSTALL/install.png', bbox=(0, 16, 640, 400), timeout=1)
self.assertTrue(os.path.isfile('CONFIG.U6'))

def tearDown(self):
os.remove('MAP')
os.remove('CONFIG.U6')
shutil.rmtree('SAVEGAME')
12 changes: 3 additions & 9 deletions tests/test_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

class TestEnd(tests.TestCase):
def testEnd(self):
with open('CONFIG.U6', 'wb') as f:
f.write(b'\x76\x6d\x61\x33\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

configuration = {
'cpu': {
'cycles': 'max',
Expand Down Expand Up @@ -66,10 +63,7 @@ def testEnd(self):
box.send_keys(' ')
box.wait_image('screenshots/END/clear.png', timeout=1)

def testEndNoArguments(self):
with open('CONFIG.U6', 'wb') as f:
f.write(b'\x76\x6d\x61\x33\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

def testNoArguments(self):
configuration = {
'cpu': {
'cycles': 'max',
Expand All @@ -83,8 +77,8 @@ def testEndNoArguments(self):
[
'-c', 'MOUNT C: .',
'-c', 'C:',
'-c', 'DEBUG END.EXE',
'-c', 'CLS',
'-c', 'END.EXE',
'-c', 'CLS'
],
configuration,
timeout_error=AssertionError,
Expand Down
5 changes: 1 addition & 4 deletions tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import tests


class TestGame(tests.TestCase):
class TestGame(tests.InstalledTestCase):
@unittest.skip('TBD')
def testGame(self):
with open('CONFIG.U6', 'wb') as f:
f.write(b'\x76\x6d\x61\x33\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

# FIXME игре нужен созданный персонаж

configuration = {
Expand Down
43 changes: 3 additions & 40 deletions tests/test_install.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,7 @@
import time

import testbox
import tests


class TestInstall(tests.TestCase):
class TestInstall(tests.InstalledTestCase):
def testInstall(self):
configuration = {
'cpu': {
'cycles': 'max',
},
'render': {
'scaler': 'normal2x forced',
},
}

with testbox.TestBox(
[
'-c', 'MOUNT C: .',
'-c', 'C:',
'-c', 'RK.COM /L:RUSSIAN.RK /F:8X16.RK',
'INSTALL.EXE',
],
configuration,
timeout_error=AssertionError,
) as box:
for keys in (
'H', # Hard disk.
'C', # Drive C:.
'5', # VGA.
'Y', # Mouse.
'1', # Adlib.
'\r', # Default port.
'Y', # Everything is correct.
'2', # Don't create character.
):
# FIXME save screenshots and pack as artifacts.
box.send_keys(keys)
time.sleep(0.1)
box.wait_image('screenshots/INSTALL/install.png', bbox=(0, 16, 640, 400), timeout=1)

with open('CONFIG.U6', 'rb') as f:
self.assertEqual(f.read(), b'\x76\x6d\x61\x33\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
with open('CONFIG.U6', 'rb') as f:
self.assertEqual(f.read(), b'\x76\x6d\x61\x33\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
33 changes: 28 additions & 5 deletions tests/test_u.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
import os
import time
import unittest

import testbox
import tests


class TestU(tests.TestCase):
class TestU(tests.InstalledTestCase):
def testExitWithDriver(self):
configuration = {
'cpu': {
'cycles': 'max',
},
'render': {
'scaler': 'normal5x',
},
}

with testbox.TestBox(
[
'-c', 'MOUNT C: .',
'-c', 'C:',
'-c', 'RK211.COM /L:RUSSIAN.RK /F:8X16.RK', # FIXME `RK.COM`
'U.EXE',
],
configuration,
timeout_error=AssertionError,
) as box:
box.send_keys('\x1b') # Esc.
box.wait_image('screenshots/U/menu.png', timeout=6)
box.send_keys('\x11') # Ctrl+Q.
box.wait_image('screenshots/U/exit.png', timeout=1)

@unittest.skip('TBD')
def testU(self):
with open('CONFIG.U6', 'wb') as f:
f.write(b'\x76\x6d\x61\x33\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

configuration = {
'cpu': {
'cycles': 'max',
Expand All @@ -25,7 +48,7 @@ def testU(self):
'-c', 'MOUNT C: .',
'-c', 'C:',
'-c', 'RK.COM /L:RUSSIAN.RK /F:8X16.RK',
# 'U.EXE',
'U.EXE',
],
configuration,
timeout_error=AssertionError,
Expand Down
Binary file added tools/RK211.COM
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/duplicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

for k, v in references.items():
if len(v) > 1:
print('WARNING', k[0], k[1], len(v), 'references')
print('WARNING', k[0], hex(k[1]), len(v), 'references:', ', '.join((hex(x['origin']) for x in v)))

0 comments on commit 4842bc7

Please sign in to comment.