https://git.reactos.org/?p=reactos.git;a=commitdiff;h=47b3e61d6217d8bd52a31…
commit 47b3e61d6217d8bd52a31d3be4fe4ff3ca404b35
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Mar 14 00:16:44 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:42 2022 +0100
[WINESYNC] msi/tests: Add tests for MsiViewFetch wraparound behaviour.
Signed-off-by: Jinoh Kang <jinoh.kang.kr(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id f26a9d093dff052e1db0c68db8801219d409cb3f by Jinoh Kang
<jinoh.kang.kr(a)gmail.com>
---
modules/rostests/winetests/msi/db.c | 83 +++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
diff --git a/modules/rostests/winetests/msi/db.c b/modules/rostests/winetests/msi/db.c
index b42cc90a955..eb087eb9711 100644
--- a/modules/rostests/winetests/msi/db.c
+++ b/modules/rostests/winetests/msi/db.c
@@ -9293,6 +9293,88 @@ static void test_view_get_error(void)
DeleteFileA(msifile);
}
+static void test_viewfetch_wraparound(void)
+{
+ MSIHANDLE db = 0, view = 0, rec = 0;
+ UINT r, i, idset, tries;
+ const char *query;
+
+ DeleteFileA(msifile);
+
+ /* just MsiOpenDatabase should not create a file */
+ r = MsiOpenDatabaseW( msifileW, MSIDBOPEN_CREATE, &db );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ query = "CREATE TABLE `phone` ( "
+ "`id` INT, `name` CHAR(32), `number` CHAR(32) "
+ "PRIMARY KEY `id`)";
+ r = run_query( db, 0, query );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
+ "VALUES('1', 'Alan', '5030581')";
+ r = run_query( db, 0, query );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
+ "VALUES('2', 'Barry', '928440')";
+ r = run_query( db, 0, query );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
+ "VALUES('3', 'Cindy', '2937550')";
+ r = run_query( db, 0, query );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ query = "SELECT * FROM `phone`";
+ r = MsiDatabaseOpenViewA( db, query, &view );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ r = MsiViewExecute( view, 0 );
+ ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r );
+
+ for (tries = 0; tries < 3; tries++)
+ {
+ winetest_push_context( "Wraparound attempt #%d", tries );
+ idset = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ winetest_push_context( "Record #%d", i );
+
+ r = MsiViewFetch( view, &rec );
+ todo_wine_if(tries > 0) ok( r == ERROR_SUCCESS, "Expected
ERROR_SUCCESS, got %d\n", r );
+ if (r != ERROR_SUCCESS)
+ {
+ winetest_pop_context();
+ break;
+ }
+
+ r = MsiRecordGetInteger(rec, 1);
+ ok(r >= 1 && r <= 3, "Expected 1 <= id <= 3, got
%d\n", r);
+ if (r < sizeof(idset) * 8)
+ {
+ ok(!(idset & (1 << r)), "Duplicate id %d\n", r);
+ idset |= 1 << r;
+ }
+
+ MsiCloseHandle(rec);
+
+ winetest_pop_context();
+ }
+
+ r = MsiViewFetch(view, &rec);
+ ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n",
r);
+
+ winetest_pop_context();
+ }
+
+ MsiViewClose(view);
+ MsiCloseHandle(view);
+ MsiCloseHandle(db);
+ DeleteFileA(msifile);
+}
+
START_TEST(db)
{
test_msidatabase();
@@ -9352,4 +9434,5 @@ START_TEST(db)
test_viewmodify_merge();
test_viewmodify_insert();
test_view_get_error();
+ test_viewfetch_wraparound();
}