Previous 15994 Revisions Next

r2567 Wednesday 7th May, 2008 at 02:05:43 UTC by Nathan Woods
[Messtest] Fallout from device refactoring
[src/mess]device.c
[src/mess/tests]mess_bebox.xml mess_coco.xml
[src/mess/tools/messtest]testmess.c

src/mess/tools/messtest/testmess.c
r2566r2567
2323#include "debug/debugcpu.h"
2424#endif /* ENABLE_DEBUGGER */
2525
26
27/***************************************************************************
28    CONSTANTS
29***************************************************************************/
30
31#define MESSTEST_ALWAYS_DUMP_SCREENSHOT      1
32
33
34
35/***************************************************************************
36    TYPE DEFINITIONS
37***************************************************************************/
38
2639typedef enum
2740{
2841   STATE_READY,
r2566r2567
3144   STATE_DONE
3245} messtest_running_state_t;
3346
47
48
3449typedef enum
3550{
3651   MESSTEST_COMMAND_END,
r2566r2567
5166   MESSTEST_COMMAND_HARD_RESET
5267} messtest_command_type_t;
5368
54struct messtest_command
69
70
71typedef struct _messtest_device_identity messtest_device_identity;
72struct _messtest_device_identity
5573{
74   const char *tag;
75   iodevice_t type;
76   int slot;
77};
78
79
80
81typedef struct _messtest_command messtest_command;
82struct _messtest_command
83{
5684   messtest_command_type_t command_type;
5785   union
5886   {
r2566r2567
6997         offs_t end;
7098         const void *verify_data;
7199         size_t verify_data_size;
72         iodevice_t device_type;
73         int device_slot;
100         messtest_device_identity device_ident;
74101      } verify_args;
75102      struct
76103      {
77104         const char *filename;
78105         const char *format;
79         iodevice_t device_type;
80         int device_slot;
81         const char *device_tag;
106         messtest_device_identity device_ident;
82107      } image_args;
83108      struct
84109      {
r2566r2567
88113   } u;
89114};
90115
91struct messtest_testcase
116
117
118typedef struct _messtest_testcase messtest_testcase;
119struct _messtest_testcase
92120{
93121   const char *name;
94122   const char *bios;
95123   const char *driver;
96124   attotime time_limit;   /* 0.0 = default */
97   struct messtest_command *commands;
125   messtest_command *commands;
98126
99127   /* options */
100128   UINT32 ram;
r2566r2567
102130   unsigned int enabled : 1;
103131};
104132
133
134
135typedef struct _messtest_specific_state messtest_specific_state;
105136struct messtest_specific_state
106137{
107   struct messtest_testcase testcase;
138   messtest_testcase testcase;
108139   int command_count;
109   struct messtest_command current_command;
140   messtest_command current_command;
110141};
111142
143
144
112145typedef enum
113146{
114147   MESSTEST_RESULT_SUCCESS,
r2566r2567
116149   MESSTEST_RESULT_RUNTIMEFAILURE
117150} messtest_result_t;
118151
119struct messtest_results
152
153
154typedef struct _messtest_results messtest_results;
155struct _messtest_results
120156{
121157   messtest_result_t rc;
122158   UINT64 runtime_hash;   /* A value that is a hash taken from certain runtime parameters; used to detect different execution paths */
r2566r2567
124160
125161
126162
127#define MESSTEST_ALWAYS_DUMP_SCREENSHOT      1
163/***************************************************************************
164    LOCAL VARIABLES
165***************************************************************************/
128166
129
130167static messtest_running_state_t state;
131168static int had_failure;
132169static attotime wait_target;
133170static attotime final_time;
134static const struct messtest_command *current_command;
171static const messtest_command *current_command;
135172static int test_flags;
136173static int screenshot_num;
137174static int format_index;
r2566r2567
143180static mess_pile command_pile;
144181static object_pool *command_pool;
145182static int command_count;
146static struct messtest_command new_command;
183static messtest_command new_command;
147184
148static struct messtest_testcase current_testcase;
185static messtest_testcase current_testcase;
149186
150187static const options_entry win_mess_opts[] =
151188{
r2566r2567
157194
158195
159196
197/***************************************************************************
198    IMPLEMENTATION
199***************************************************************************/
200
160201static astring *assemble_software_path(astring *str, const game_driver *gamedrv, const char *filename)
161202{
162203   if (osd_is_absolute_path(filename))
r2566r2567
264305
265306
266307
267static messtest_result_t run_test(int flags, struct messtest_results *results)
308static messtest_result_t run_test(int flags, messtest_results *results)
268309{
269310   const game_driver *driver;
270311   messtest_result_t rc;
r2566r2567
320361      fullpath = assemble_software_path(astring_alloc(), driver, current_command->u.image_args.filename);
321362
322363      /* get the option name */
323      device_opt = device_typename(current_command->u.image_args.device_type);
364      device_opt = device_typename(current_command->u.image_args.device_ident.type);
324365
325366      /* set the option */
326367      options_set_string(opts, device_opt, astring_c(fullpath), OPTION_PRIORITY_CMDLINE);
r2566r2567
656697}
657698
658699
700
701static const device_config *find_device_by_identity(running_machine *machine, const messtest_device_identity *ident)
702{
703   const device_config *device;
704
705   /* look up the image slot */
706   if (ident->type == IO_UNKNOWN)
707   {
708      /* no device_type was specified; use the new preferred mechanism */
709      device = device_list_find_by_tag(machine->config->devicelist, DEVICE_TYPE_WILDCARD, ident->tag);
710   }
711   else if (ident->tag != NULL)
712   {
713      /* perform a legacy lookup by tag */
714      device = image_from_devtag_and_index(machine, ident->tag, ident->slot);
715   }
716   else
717   {
718      /* perform a legacy lookup by device type */
719      device = image_from_devtype_and_index(ident->type, ident->slot);
720   }
721
722   /* did the image slot lookup fail? */
723   if (device == NULL)
724   {
725      state = STATE_ABORTED;
726      report_message(MSG_FAILURE, "Device '%s %i' does not exist",
727         device_typename(ident->type), ident->slot);
728   }
729
730   return device;
731}
732
733
734
659735static void command_image_loadcreate(running_machine *machine)
660736{
661737   const device_config *image;
662   int device_type;
663   int device_slot;
664   const char *device_tag;
665738   int i, format_index = 0;
666739   const char *filename;
667740   const char *format;
r2566r2567
672745   int success;
673746   const game_driver *gamedrv;
674747
675   device_slot = current_command->u.image_args.device_slot;
676   device_type = current_command->u.image_args.device_type;
677   device_tag = current_command->u.image_args.device_tag;
678
679748   /* look up the image slot */
680   if (device_tag)
681      image = image_from_devtag_and_index(machine, device_tag, device_slot);
682   else
683      image = image_from_devtype_and_index(device_type, device_slot);
684   if (!image)
685   {
686      state = STATE_ABORTED;
687      report_message(MSG_FAILURE, "Image slot '%s %i' does not exist",
688         device_typename(device_type), device_slot);
749   image = find_device_by_identity(machine, &current_command->u.image_args.device_ident);
750   if (image == NULL)
689751      return;
690   }
752
691753   info = image_device_getinfo(machine->config, image);
692754   file_extensions = info.file_extensions;
693755
r2566r2567
852914   verify_data = (const UINT8 *) current_command->u.verify_args.verify_data;
853915   verify_data_size = current_command->u.verify_args.verify_data_size;
854916
855   image = image_from_devtype_and_index(current_command->u.verify_args.device_type, current_command->u.verify_args.device_slot);
917   /* look up the device */
918   image = find_device_by_identity(machine, &current_command->u.verify_args.device_ident);
919   if (image == NULL)
920      return;
921
856922   filename = image_filename(image);
857   if (!filename)
923   if (filename == NULL)
858924   {
859925      state = STATE_ABORTED;
860926      report_message(MSG_FAILURE, "Failed verification: Device Not Loaded");
r2566r2567
10591125{
10601126   if (pile_write(&command_pile, &new_command, sizeof(new_command)))
10611127      return FALSE;
1062   current_testcase.commands = (struct messtest_command *) pile_getptr(&command_pile);
1128   current_testcase.commands = (messtest_command *) pile_getptr(&command_pile);
10631129   command_count++;
10641130   return TRUE;
10651131}
r2566r2567
12081274
12091275
12101276
1211static void node_image(xml_data_node *node, messtest_command_type_t command)
1277static int get_device_identity_tags(xml_data_node *node, messtest_device_identity *ident)
12121278{
12131279   xml_attribute_node *attr_node;
12141280   const char *s2;
1215   int preload, device_type;
12161281
1282   /* clear out the result */
1283   memset(ident, 0, sizeof(*ident));
1284
1285   /* 'type' attribute */
1286   attr_node = xml_get_attribute(node, "type");
1287   if (attr_node != NULL)
1288   {
1289      s2 = attr_node->value;
1290
1291      ident->type = device_typeid(s2);
1292      if (ident->type <= IO_UNKNOWN)
1293      {
1294         error_baddevicetype(s2);
1295         return FALSE;
1296      }
1297   }
1298   else
1299   {
1300      /* the device type was unspecified */
1301      ident->type = IO_UNKNOWN;
1302   }
1303
1304   /* 'slot' attribute */
1305   attr_node = xml_get_attribute(node, "slot");
1306   ident->slot = (attr_node != NULL) ? atoi(attr_node->value) : 0;
1307
1308   /* 'tag' attribute */
1309   attr_node = xml_get_attribute(node, "tag");
1310   ident->tag = (attr_node != NULL) ? attr_node->value : NULL;
1311
1312   return TRUE;
1313}
1314
1315
1316
1317static void node_image(xml_data_node *node, messtest_command_type_t command)
1318{
1319   xml_attribute_node *attr_node;
1320   int preload;
1321
12171322   memset(&new_command, 0, sizeof(new_command));
12181323   new_command.command_type = command;
12191324
r2566r2567
12271332   attr_node = xml_get_attribute(node, "filename");
12281333   new_command.u.image_args.filename = attr_node ? attr_node->value : NULL;
12291334
1230   /* 'type' attribute */
1231   attr_node = xml_get_attribute(node, "type");
1232   if (!attr_node)
1233   {
1234      error_missingattribute("type");
1335   /* 'tag', 'type', 'slot' attributes */
1336   if (!get_device_identity_tags(node, &new_command.u.image_args.device_ident))
12351337      return;
1236   }
1237   s2 = attr_node->value;
12381338
1239   device_type = device_typeid(s2);
1240   if (device_type < 0)
1241   {
1242      error_baddevicetype(s2);
1243      return;
1244   }
1245   new_command.u.image_args.device_type = device_type;
1246
1247   /* 'slot' attribute */
1248   attr_node = xml_get_attribute(node, "slot");
1249   new_command.u.image_args.device_slot = attr_node ? atoi(attr_node->value) : 0;
1250
12511339   /* 'format' attribute */
12521340   format_index = 0;
12531341   attr_node = xml_get_attribute(node, "format");
12541342   new_command.u.image_args.format = attr_node ? attr_node->value : NULL;
12551343
1256   /* 'tag' attribute */
1257   attr_node = xml_get_attribute(node, "tag");
1258   new_command.u.image_args.device_tag = attr_node ? attr_node->value : NULL;
1259
12601344   if (!append_command())
12611345   {
12621346      error_outofmemory();
r2566r2567
13411425
13421426static void node_imageverify(xml_data_node *node)
13431427{
1344   xml_attribute_node *attr_node;
1345   const char *s;
1346   iodevice_t device_type;
13471428   void *new_buffer;
13481429   mess_pile pile;
13491430
r2566r2567
13511432   memset(&new_command, 0, sizeof(new_command));
13521433   new_command.command_type = MESSTEST_COMMAND_VERIFY_IMAGE;
13531434
1354   /* 'type' attribute */
1355   attr_node = xml_get_attribute(node, "type");
1356   s = attr_node ? attr_node->value : NULL;
1357   if (!s)
1358   {
1359      error_missingattribute("type");
1435   /* 'tag', 'type', 'slot' attributes */
1436   if (!get_device_identity_tags(node, &new_command.u.verify_args.device_ident))
13601437      return;
1361   }
13621438
1363   device_type = device_typeid(s);
1364   if (device_type < 0)
1365   {
1366      error_baddevicetype(s);
1367      return;
1368   }
1369
1370   new_command.u.verify_args.device_type = device_type;
1371
13721439   pile_init(&pile);
13731440   messtest_get_data(node, &pile);
13741441   new_buffer = pool_malloc(command_pool, pile_size(&pile));
src/mess/tests/mess_coco.xml
r2566r2567
7070<test name="coco_006" driver="coco2b">
7171   <!-- This test tests printing -->
7272   <wait time="2"/>
73   <imagecreate type="prin"/>
73   <imagecreate tag="bitbanger"/>
7474   <input>?#-2, "FOO";&#13;</input>
7575   <wait time="4"/>
76   <imageverify type="prin">"FOO"</imageverify>
76   <imageverify tag="bitbanger">"FOO"</imageverify>
7777</test>
7878
7979<test name="coco_bug993" driver="coco2b" ramsize="16k">
src/mess/tests/mess_bebox.xml
r2566r2567
11<tests>
22
3<test name="bebox_000" driver="bebox">
3<test name="bebox_000" driver="bebox" enabled="0">
44   <wait time="3"/>
55   <checkblank/>
66</test>
src/mess/device.c
r2566r2567
642642   const device_config *dev;
643643   const struct IODevice *iodev;
644644
645   assert(id < device_count(Machine, type));
646
647645   for (dev = device_list_first(Machine->config->devicelist, MESS_DEVICE); dev != NULL; dev = device_list_next(dev, MESS_DEVICE))
648646   {
649647      iodev = mess_device_from_core_device(dev);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team