winedbg and program stdout

2012-04-21 Thread Ilya Basin
When I debug a program with winedbg, it's output never goes to the
same terminal. If it's compiled with -mconsole, it goes to a new
console window; if compiled with -mwindows, the output is discarded.
Any way to change this behavior?





winedbg-eclipse - winedbg wrapper for Eclipse IDE

2012-04-14 Thread Ilya Basin
- Get Eclipse 3.7.2 CDT
- Import existing code as Makefile (a wine component or a standalone
- winelib program)
- Check Automate discovery in project properties/C/C++ Build/Discovery
- Create a standart C/C++ Application debug configuration
- Set *.exe.so as application
- Set winedbg-eclipse as GDB debugger
- fix bugs faster!
?xml version=1.0 encoding=UTF-8 standalone=no?
launchConfiguration type=org.eclipse.cdt.launch.applicationLaunchType
booleanAttribute key=org.eclipse.cdt.dsf.gdb.AUTO_SOLIB value=true/
listAttribute key=org.eclipse.cdt.dsf.gdb.AUTO_SOLIB_LIST/
stringAttribute key=org.eclipse.cdt.dsf.gdb.DEBUG_NAME 
value=/media/ARCHLINUXOLD/1/builds/wine/src/wine/winedbg-eclipse/
booleanAttribute key=org.eclipse.cdt.dsf.gdb.DEBUG_ON_FORK value=false/
stringAttribute key=org.eclipse.cdt.dsf.gdb.GDB_INIT value=.gdbinit/
booleanAttribute key=org.eclipse.cdt.dsf.gdb.NON_STOP value=false/
booleanAttribute key=org.eclipse.cdt.dsf.gdb.REVERSE value=false/
listAttribute key=org.eclipse.cdt.dsf.gdb.SOLIB_PATH/
booleanAttribute key=org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND 
value=false/
booleanAttribute 
key=org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab.DEFAULTS_SET
 value=true/
intAttribute key=org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR 
value=2/
stringAttribute key=org.eclipse.cdt.launch.COREFILE_PATH value=/
stringAttribute key=org.eclipse.cdt.launch.DEBUGGER_ID value=gdb/
stringAttribute key=org.eclipse.cdt.launch.DEBUGGER_START_MODE value=run/
booleanAttribute key=org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN 
value=true/
stringAttribute key=org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL 
value=main/
stringAttribute key=org.eclipse.cdt.launch.PROGRAM_NAME 
value=regedit.exe.so/
stringAttribute key=org.eclipse.cdt.launch.PROJECT_ATTR value=regedit/
booleanAttribute key=org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR 
value=true/
stringAttribute key=org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR 
value=0.1052470212/
booleanAttribute key=org.eclipse.cdt.launch.use_terminal value=true/
listAttribute key=org.eclipse.debug.core.MAPPED_RESOURCE_PATHS
listEntry value=/regedit/
/listAttribute
listAttribute key=org.eclipse.debug.core.MAPPED_RESOURCE_TYPES
listEntry value=4/
/listAttribute
stringAttribute key=org.eclipse.dsf.launch.MEMORY_BLOCKS value=lt;?xml 
version=quot;1.0quot; encoding=quot;UTF-8quot; 
standalone=quot;noquot;?gt;#10;lt;memoryBlockExpressionList 
context=quot;reserved-for-future-usequot;/gt;#10;/
/launchConfiguration
#!/bin/bash
#
#   winedbg-eclipse - winedbg wrapper for Eclipse IDE
#
#   2012-04-14 first draft
#

GDB=gdb
SETSID=setsid
MKTEMPU=mktemp --tmpdir -u winedbg-eclipse.XX
TRACEFILE=$HOME/winedbg-eclipse.log

# debug with installed wine
WINECMD=/usr/bin/wine
WINEBINARY=/usr/bin/wine

# debug with wine sources
#export WINEPREFIX=~/.winetest # don't mess up my ~/.wine
#WINEBUILDDIR=/media/ARCHLINUXOLD/1/builds/wine/src/wine
#WINECMD=$WINEBUILDDIR/wine
#WINEBINARY=$WINEBUILDDIR/loader/wine

set -e 

case $* in
--version)
  exec $GDB $@
  ;;
--interpreter mi2 --nx)
  ;;
*)
  echo unknown arguments: $@ 2
  exit 1
  ;;
esac

fn_commandfilter() {

  while read -r s; do
printf 'you wrote: %s\n' $s 3
set -- $s
case $1 in
*-file-exec-and-symbols)
  echo recognized command: -file-exec-and-symbols 3

  s=$1 $WINEBINARY

  printf 'I send: %s\n' $s 3
  printf '%s\n' $s

  [ $2 != --thread-group ] || shift 2
  file=$2

  # need to send 'target remote' immediatly, so breakpoints properly 
restored

  fifo=`$MKTEMPU`
  mkfifo $fifo

  set -- $WINECMD winedbg --gdb --no-start $file

  echo executing command: $SETSID $@ /dev/null $fifo  3
  # run winedbg protected from C^c
  $SETSID $@ /dev/null $fifo 21 
  winedbg_pid=$!
  echo waiting 10 seconds for 'target remote' 3
  {
sleep 10
echo wait timeout. killing winedbg 3
kill $winedbg_pid
  } 
  killer_pid=$!
  while read -r s $fifo ; do
printf 'winedbg: %s\n' $s 3
case $s in
target *)
  #s=$numcmd-target-select ${s/target /}
  printf 'I send: %s\n' $s 3
  printf '%s\n' $s
  break;
  ;;
esac
  done
  kill $killer_pid

  echo reading winedbg in background 3
  while read -r s $fifo ; do
printf 'winedbg: %s\n' $s 3
  done 

  rm $fifo

  continue
  ;;
*-exec-run)
  echo recognized command: -exec-run 3
  # dummy command because eclipse expects $numcmd^done
  numcmd=${s/-*/}
  echo $numcmd^done 4
  continue
  ;;
esac
printf 'I send: %s\n' $s 3
printf '%s\n' $s
  done
}

exec 3$TRACEFILE

# save original stdout for fake GDB replies
exec 41


{
  echo --
  echo
  echo
  echo
} 3

fifo=`$MKTEMPU`
echo mkfifo $fifo 3
mkfifo $fifo

fn_commandfilter 0 $fifo 
commandfilter_pid=$!

trap 'kill 

Re[2]: automate winedbg IDE integration

2012-04-14 Thread Ilya Basin
I've already written a wrapper (see my other mail winedbg-eclipse -
winedbg wrapper for Eclipse IDE)
There are some problems, however.

EP do you have a trace of the gdb commands ?

gdb --version
gdb --interpreter mi2 --nx

1-list-features
2-environment-cd /media/ARCHLINUXOLD/1/builds/wine/src/wine/programs/regedit
3-gdb-set breakpoint pending on
4-gdb-set detach-on-fork on
5-enable-pretty-printing
6source .gdbinit
7-gdb-set target-async off
8-gdb-set auto-solib-add on
9-file-exec-and-symbols --thread-group i1 
/media/ARCHLINUXOLD/1/builds/wine/src/wine/programs/regedit/regedit.exe.so
10-gdb-set --thread-group i1 args testexport
11-list-thread-groups --available
12-break-insert --thread-group i1 -f 
/media/ARCHLINUXOLD/1/builds/wine/src/wine/programs/regedit/regproc.c:1092
13-break-insert --thread-group i1 -f 
/media/ARCHLINUXOLD/1/builds/wine/src/wine/programs/regedit/regproc.c:
14-break-insert --thread-group i1 -t -f main
15-inferior-tty-set --thread-group i1 /dev/pts/0
16-exec-run --thread-group i1



-- 





automate winedbg IDE integration

2012-04-13 Thread Ilya Basin
Hi developers. There's a manual on this page:
http://www.winehq.org/docs/winedev-guide/dbg-others

 Start the Wine debugger with a command line like:
 winedbg --gdb --no-start name_of_exe_to_debug.exe
 Start ddd
 In ddd, use the 'Open File' or 'Open Program' to point to the Wine executable 
 (which is either wine-pthread or wine-kthread depending on your settings).
 In the output of 1/, there's a line like
 target remote localhost:32878
 copy that line and paste into ddd command pane (the one with the (gdb) 
 prompt) 

So many steps. Is there an easier way? Or maybe everyone use plain
winedbg without any IDE?






Re: automate winedbg IDE integration

2012-04-13 Thread Ilya Basin
 which IDE do you have in mind ?
Eclipse or Netbeans. Eclipse 3.7.2 looks promising. It even
managed to detect -I and -D compiler options in the wine makefiles.

I didn't work with Netbeans for long. The last time I had to manually
set all the include directories and macros.

 some IDE provide sufficient parametrisation of gdb launching so that
 you can use directly
winedbg --gdb nameofexe.exe
Unfortunately, Eclipse passes nameofexe.exe not via command line,
but as a GDB command.





XTestFakeKeyEvent events postponed until wine process exits

2012-03-24 Thread Ilya Basin
Hi list. Currently SendInput() works only with wine windows. I need to
send keypresses to all windows, so I created a winelib dll that uses
XTestFakeKeyEvent. I call this function from a wine process, but all
my fake key presses wait for the process to exit.

What is the reason?






signal(SIGCHLD,SIG_DFL) before exec()

2011-05-04 Thread Ilya Basin
Hi list. I suffer from this bug: http://bugs.winehq.org/show_bug.cgi?id=27014
In wine sources there're not so many places where exec(3) family is
used. In some places SIGCHLD and SIGPIPE are restored to default
before calling exec(), in others they aren't. What's the difference?

Can anyone explain me the why SIGCHLD not restored to default
before calling execvp() here:
http://source.winehq.org/source/libs/port/spawn.c?v=wine-1.3.19#L42
int spawnvp(int mode, const char *cmdname, const char *const argv[])
{
...
 if (mode == _P_OVERLAY)
 {
 execvp(cmdname, (char **)argv);
 /* if we get here it failed */
 #ifdef ENOTSUP
 if (errno != ENOTSUP)  /* exec fails on MacOS if the process has 
multiple threads */
 #endif
 return -1;
 }

Because it's not forked and if execvp() fails, we end up with the
default handler?





Feature Request: winefile: some way to open terminal in current folder

2010-12-26 Thread Ilya Basin
A typical scenario:
- download a file with uTorrent 
- select Open containing folder
- ???
- use a native program to work with the downloaded file

I think, it would be convenient to add a button to start a terminal or
do xdg-open .





















Full path to wine executable in generated .desktop files

2010-12-18 Thread Ilya Basin
When you install a program, some desktop files are put here:
~/.local/share/applications/wine/
~/Desktop/

  [Desktop Entry]
  Name=Microsoft Office Access 2003
  Exec=env WINEPREFIX=/home/leniviy/.wine wine ...

I have 2 wine instances: official in /usr and patched in
/opt/wine-csshack . Because of that I would like to have
/opt/wine-csshack/bin/wine, not just wine in the generated
.desktop files.

What can go wrong if we do so?





winedbg --gdb shows multiple segfaults during any app startup

2010-12-10 Thread Ilya Basin
In both 1.3.8 and git winedbg --gdb or plain gdb catches several
segfaults, but if I ignore them, the program works.

$ CC=ccache gcc ./configure CFLAGS=-g -O0
make
./wine winedbg.exe --gdb notepad

Wine-gdb cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x7e942cf4 in create_alpha_bitmap (color=0x33c, mask=0x338, src_info=0x1319a8, 
color_bits=0x7ebf411c) at cursoricon.c:664
664 ptr[0] = ptr[0] * alpha / 255;
Wine-gdb 
Continuing.
...
Program exited normally.
Wine-gdb quit
[...@il wine-git]$ wine winedbg.exe --gdb notepad
001a:001b: create process 'C:\windows\system32\notepad.exe'/0x1106d0 
@0x7ed97360 (00)
001a:001b: create thread I @0x7ed97360
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i686-pc-linux-gnu.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
001a:001b: loads DLL C:\windows\system32\KERNEL32.dll @0x7b81 (00)
001a:001b: loads DLL C:\windows\system32\ntdll.dll @0x7bc1 (00)
001a:001b: loads DLL C:\windows\system32\advapi32.dll @0x7e82 (00)
001a:001b: loads DLL C:\windows\system32\gdi32.dll @0x7e88 (00)
001a:001b: loads DLL C:\windows\system32\version.dll @0x7eff (00)
001a:001b: loads DLL C:\windows\system32\user32.dll @0x7e92 (00)
001a:001b: loads DLL C:\windows\system32\shlwapi.dll @0x7ea7 (00)
001a:001b: loads DLL C:\windows\system32\comctl32.dll @0x7e72 (00)
001a:001b: loads DLL C:\windows\system32\shell32.dll @0x7ead (00)
001a:001b: loads DLL C:\windows\system32\winspool.drv @0x7e6e (00)
001a:001b: loads DLL C:\windows\system32\comdlg32.dll @0x7ecc (00)
001a:001b: loads DLL C:\windows\system32\msvcrt.dll @0x7e66 (00)
001a:001b: loads DLL C:\windows\system32\imm32.dll @0x7e20 (00)
001a:001b: loads DLL C:\windows\system32\winex11.drv @0x7e39 (00)
001a:001b: loads DLL C:\windows\system32\uxtheme.dll @0x7e1b (00)
001a:001b: exception code=0xc005
Unknown or malformed query Attached
0x7e942cf4 in create_alpha_bitmap (color=0x318, mask=0x314, src_info=0x131808, 
color_bits=0x7ebf5854) at cursoricon.c:664
664 ptr[0] = ptr[0] * alpha / 255;
trace: 98 = 80
Wine-gdb cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x7e942cf4 in create_alpha_bitmap (color=0x33c, mask=0x338, src_info=0x1319a8, 
color_bits=0x7ebf411c) at cursoricon.c:664
664 ptr[0] = ptr[0] * alpha / 255;
Wine-gdb bt
#0  0x7e942cf4 in create_alpha_bitmap (color=0x33c, mask=0x338, 
src_info=0x1319a8, color_bits=0x7ebf411c) at cursoricon.c:664
#1  0x7e943134 in create_icon_bitmaps (bmi=0x7ebf40f4, width=32, height=32, 
color=0x33fa04, mask=0x33fa00, alpha=0x33f9fc) at cursoricon.c:730
#2  0x7e9434c5 in CURSORICON_CreateIconFromBMI (bmi=0x7ebf40f4, 
module=0x7ead, resname=0x1, rsrc=0x7eb7f130, hotspot=..., bIcon=1, 
width=32, height=32, cFlag=32768) at cursoricon.c:801
#3  0x7e9448c5 in CURSORICON_Load (hInstance=0x7ead, name=0x1, width=32, 
height=32, depth=32, fCursor=0, loadflags=32768) at cursoricon.c:1254
#4  0x7e947a31 in LoadImageW (hinst=0x7ead, name=0x1, type=1, desiredx=32, 
desiredy=32, loadflags=32768) at cursoricon.c:2292
#5  0x7e9476a9 in LoadImageA (hinst=0x7ead, name=0x1 Address 0x1 out of 
bounds, type=1, desiredx=32, desiredy=32, loadflags=32768) at cursoricon.c:2233
#6  0x7eafc2cc in SIC_Initialize () at iconcache.c:419
#7  0x7eb096d4 in DllMain (hinstDLL=0x7ead, fdwReason=1, fImpLoad=0x1) at 
shell32_main.c:1197
#8  0x7eb55caa in __wine_spec_dll_entry (inst=0x7ead, reason=1, 
reserved=0x1) at dll_entry.c:40
#9  0x7bc4d1a9 in call_dll_entry_point () at loader.c:137
#10 0x7bc4f472 in MODULE_InitDLL (wm=0x1107e8, reason=1, lpReserved=0x1) at 
loader.c:982
#11 0x7bc4f7f8 in process_attach (wm=0x1107e8, lpReserved=0x1) at loader.c:1071
#12 0x7bc4f7a4 in process_attach (wm=0x110620, lpReserved=0x1) at loader.c:1063
#13 0x7bc4f7a4 in process_attach (wm=0x1106a8, lpReserved=0x1) at loader.c:1063
#14 0x7bc537bf in attach_process_dlls (wm=0x1106a8) at loader.c:2539
#15 0xb7675e31 in wine_call_on_stack () at port.c:84
#16 0x7bc53d65 in LdrInitializeThunk (kernel_start=0x7b85cf7a, unknown2=0, 
unknown3=0, unknown4=0) at loader.c:2661
#17 0x7b85d8ba in __wine_kernel_init () at process.c:1166
#18 0x7bc54560 in __wine_process_init () at loader.c:2876
#19 0xb7674711 in wine_init (argc=2, argv=0xbfb87d68, error=0xbfb878ac , 
error_size=1024) at loader.c:831
#20 0x7bf01220 in main (argc=2, argv=0xbfb87d68) at main.c:218
Wine-gdb cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x7e942cf4 in create_alpha_bitmap (color=0x360, mask=0x35c, src_info=0x1319a8, 
color_bits=0x7ebf5854) at cursoricon.c:664
664 

shell32_test64.exe shlexec: 5-6 DDE tests always fail on testbot W7PROX64

2010-07-20 Thread Ilya Basin
M VM   StatusNumber of test failures
M WINEBUILDcompleted 
M W98SEcompleted 0
M WNT4WSSP6completed 0
M W2KPROSP4completed 0
M WXPPROSP3completed 0
M W2K3R2SESP2  completed 0
M WVISTAADMcompleted 0
M W2K8SE   completed 0
M W7PROcompleted 0
M W7PROX64 completed 0
M W7PROX64 completed 5

M === WINEBUILD (build) ===
M No build failures found

M === W98SE (32 bit shlexec) ===
M No test failures found

M === WNT4WSSP6 (32 bit shlexec) ===
M No test failures found

M === W2KPROSP4 (32 bit shlexec) ===
M No test failures found

M === WXPPROSP3 (32 bit shlexec) ===
M No test failures found

M === W2K3R2SESP2 (32 bit shlexec) ===
M No test failures found

M === WVISTAADM (32 bit shlexec) ===
M No test failures found

M === W2K8SE (32 bit shlexec) ===
M No test failures found

M === W7PRO (32 bit shlexec) ===
M No test failures found

M === W7PROX64 (32 bit shlexec) ===
M No test failures found

M === W7PROX64 (64 bit shlexec) ===

M shell32:
M shlexec.c:1738: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt7045.tmp\test file.sde, null, null) 
failed: rc=29 err=2
M shlexec.c:1738: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt7045.tmp\test file.sde, null, null) 
failed: rc=29 err=2
M shlexec.c:1738: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt7045.tmp\test file.sde, null, null) 
failed: rc=29 err=2
M shlexec.c:1738: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt7045.tmp\test file.sde, null, null) 
failed: rc=29 err=2
M shlexec.c:1738: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt7045.tmp\test file.sde, null, null) 
failed: rc=29 err=2

Hi! I sent multiple different patches for shlexec and ever since
W7PROX64 (64 bit shlexec) is used by testbot, 5 DDE tests always fail
on it. I can't reproduce it on local W7PROX64: No shlexec tests fail.

test.winehq.org has the same problem
http://test.winehq.org/data/d494bda30f1b5b9bc37f094bd8874d3aeeaf8840/win7_wtb-w7prox64-64/shell32:shlexec.html

Another question: winetest64-latest.exe extracts individual test
binaries to the temp folder and runs them. How do you extract the
binaries without running?

-- 





Re[2]: base addresses of kernel32

2010-07-05 Thread Ilya Basin
TC In that case you should check if you have prelink installed and
TC then configure and build wine.

Kinda works. kernel32 and user32 seem to be on their places.
I Wonder why our package maintainers didn't mark prelink as
makedepends. Maybe it's not 100% reliable? For example if one of the
wine's dependencies, say, libpthread or libc gets updated?

-- 





Re[2]: base addresses of kernel32

2010-07-04 Thread Ilya Basin
 int main() {
   HMODULE hKernel32 = GetModuleHandle(kernel32.dll);
   printf(0x%8x\n, hKernel32);
 }

 [...@il winetest]$ wine a.exe
 0x7edf
 [...@il winetest]$ wine a.exe
 0x7edf
 [...@il winetest]$ wine a.exe
 0x7ede

TC Is this on Linux?

yes

-- 





How do you make x64 crosstests?

2010-06-25 Thread Ilya Basin
_





structure has #pragma pack(8) in Windows SDK (AMD64) and #pragma pack(1) in wine headers

2010-06-25 Thread Ilya Basin
The struct in question is CSFV defined in shlobh.h. If I try to
compile shell32_test for x64 using headers from windows 2008 SDK, I
get assertion failure here:
http://source.winehq.org/source/dlls/shell32/tests/generated.c?v=wine-1.2-rc5#L1395

Is it normal for wine to have different structure packing?





Re[2]: shell32: remove unneeded parsing of SHELLEXECUTEINFO.lpFile [try 3]

2010-04-24 Thread Ilya Basin
PV Hi Ilya,

PV In your last email on wine-devel about this subject you mentioned adding 
PV some extra tests. There was at least some communication with you and the 
PV author of that piece you are now removing. The reason for that piece was 
PV shown in a code-snippet he gave and adding tests for that specific case 
PV would be worthwhile I think.



Hi Paul. Yore're right, I forgot.
IB Add a new verb that has '%*' in it. I put the reply from M.Fuchs in
IB the bottom. It seems that it was related to .lnk handling.
Then postponing till my next slack period, the more so I got another
e-mail:

=== W7PROX64 (32 bit shlexec) ===
No test failures found

=== W7PROX64 (64 bit shlexec) ===

shell32:
shlexec.c:1609: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt1F81.tmp\test file.sde, null, null) 
failed: rc=29 err=2
shlexec.c:1609: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt1F81.tmp\test file.sde, null, null) 
failed: rc=29 err=2
shlexec.c:1609: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt1F81.tmp\test file.sde, null, null) 
failed: rc=29 err=2
shlexec.c:1609: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt1F81.tmp\test file.sde, null, null) 
failed: rc=29 err=2
shlexec.c:1609: Test failed: ShellExecuteEx(null, 
C:\Users\winetest\AppData\Local\Temp\wt1F81.tmp\test file.sde, null, null) 
failed: rc=29 err=2

Strange, isn't it? I wonder if the tests succeeded without my patch.


I was wrong in the following part:
IB But currently I'm more worried by
IB http://bugs.winehq.org/show_bug.cgi?id=19385
IB ( the 'wine start' launcher does not open MS Office documents that
IB have spaces in their path )

IB If the verb\command doesn't contain '%', e.g.
IB 'C:\PROGRA~1\MICROS~2\OFFICE11\WINWORD.EXE /n /dde'
IB it's argyfied incorrectly

IB Now there's no test verb without '%', I think I should add it
IB and add related tests.

Later I reviewed the code and learned that this was
unrelated to the bug with lpFile parsing.
I sent another patch, so the bug 19385 is fixed now.
We can still add more DDE tests, but, I repeat, it's not related to
the current topic.


-- 





Re[2]: shell32: remove unneeded parsing of SHELLEXECUTEINFO.lpFile [try 2]

2010-03-23 Thread Ilya Basin
PV The only thing I'm wondering is why this big piece was added in the
PV first place (2004) but that in itself is of course no guarantee it was 
PV needed.

PV Is it possible to create more tests or is everything possible already
PV catered for by that one test?
Add a new verb that has '%*' in it. I put the reply from M.Fuchs in
the bottom. It seems that it was related to .lnk handling.

But currently I'm more worried by
http://bugs.winehq.org/show_bug.cgi?id=19385
( the 'wine start' launcher does not open MS Office documents that
have spaces in their path )

If the verb\command doesn't contain '%', e.g.
'C:\PROGRA~1\MICROS~2\OFFICE11\WINWORD.EXE /n /dde'
it's argyfied incorrectly

Now there's no test verb without '%', I think I should add it
and add related tests.



MF well you see it's a long time ago and I don't know the exact reason for 
this code. But it may help if I show you the first occurence of this code 
snippet I could get hold of in the ReactOS repository find at 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/shell32/shlexec.c?revision=7409view=markuppathrev=7409
 .
MF  
MF  
MF   927 /* The following code is needed for example to resolve a shortcut
MF   928to control panel applet Keyboard, since this is accessed 
using
MF   929rundll32.exe shell32.dll,Control_RunDLL %1,%* with a command 
line
MF   930parameter received from ISF_ControlPanel_fnGetDisplayNameOf(). 
*/
MF   931 if (!*szCommandline) {
MF   932   if (*szApplicationName == '') {
MF   933   LPCSTR src = szApplicationName + 1;
MF   934   LPSTR dst = fileName;
MF   935 
MF   936   while(*src  *src!='')
MF   937 *dst++ = *src++;
MF   938 
MF   939   *dst = '\0';
MF   940 
MF   941   if (*src == '')
MF   942 for(++src; isspace(*src); )
MF   943 ++src;
MF   944 
MF   945   strcpy(szCommandline, src);
MF   946   }
MF   947   else
MF   948   {
MF   949   LPSTR space, s;
MF   950   char buffer[MAX_PATH], xlpFile[MAX_PATH];
MF   951 
MF   952   LPSTR beg = szApplicationName;
MF   953   for(s=beg; space=strchr(s, ' '); s=space+1) {
MF   954 int idx = space-szApplicationName;
MF   955 strncpy(buffer, szApplicationName, idx);
MF   956 buffer[idx] = '\0';
MF   957 
MF   958 if (SearchPathA(sei-lpDirectory, buffer, .exe, 
sizeof(xlpFile), xlpFile, NULL))
MF   959 {
MF   960 /* separate out command from parameter string */
MF   961 LPCSTR p = space + 1;
MF   962 
MF   963 while(isspace(*p))
MF   964   ++p;
MF   965 
MF   966 strcpy(szCommandline, p);
MF   967 *space = '\0';
MF   968 
MF   969 break;
MF   970 }
MF   971   }
MF   972 
MF   973   strcpy(fileName, szApplicationName);
MF   974   }
MF   975 } else
MF   976   strcpy(fileName, szApplicationName);
MF   977 
MF   978 lpFile = fileName;
MF   979 
MF   980 if (szCommandline[0]) {
MF   981 strcat(szApplicationName,  );
MF   982 strcat(szApplicationName, szCommandline);
MF   983 }
MF   984 
MF   985 retval = execfunc(szApplicationName, NULL, sei, FALSE);
MF   986 if (retval  32)
MF   987 {
MF   988   /* Now, that we have successfully launched a process, we can free 
the PIDL.
MF   989   It may have been used before for %I command line options. */
MF   990   if (tmpPidl)
MF   991   SHFree(tmpPidl);
MF   992 
MF   993 TRACE(execfunc: retval=%d sei-hInstApp=%p\n, retval, 
sei-hInstApp);
MF   994 return TRUE;
MF   995 }
MF  
MF Please note the comment at the top, which may lead you to a valid test case 
for this algorithm in SHELL_execute(). This text remained there until revision 
7522, where it was replaced by the current text separate out command line 
arguments from executable file name. The code itself was extended to handle 
more cases and ported to UNICODE strings until now.
MF May be it is now superflous because of some other code changes (just a 
guess: FindExecutable may be a candidate). But may it is still necessary to 
correctly handle some rare cases when executing shell/explorer related calls 
with complicated command line arguments.
MF  
MF  

MF Regards,
MF  
MF Martin



-- 





Re: shell32: remove unneeded parsing of SHELLEXECUTEINFO.lpFile [try 2]

2010-03-22 Thread Ilya Basin
Hi! Sorry for being annoying, will you accept my patch?
http://www.winehq.org/pipermail/wine-patches/2010-March/086009.html

-- 





Re: makefiles: Use the standard C_SRCS variable as the list of test files

2010-03-22 Thread Ilya Basin
Looks like after this commit:
http://source.winehq.org/git/wine.git/?a=commit;h=6164ce2d820546ae5b26eb504bc108091c5679ea

the command
./tools/winapi/msvcmaker --no-wine
silently fails: only 'winetest.dsp' created





Re[2]: shell32: remove unneeded parsing of SHELLEXECUTEINFO.lpFile

2010-03-18 Thread Ilya Basin
PV If this is no longer a todo_wine you should change the filename_tests
PV struct:
You're right.

Do you have any clue why this block of code was added to
SHELL_execute() ?






Re[2]: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 7]

2010-03-17 Thread Ilya Basin
There's a block of code in dlls/shell32/shlexec.c
http://source.winehq.org/git/wine.git/?a=blob;f=dlls/shell32/shlexec.c;h=a81cada91fed264816a0946c06e83a00b7fb6484;hb=HEAD#l1681

It specially handles lpFile with '' or containing spaces. Does anyone
know a real situation when you need this handling? If I disable this
block:
  /* separate out command line arguments from executable file name */
  if (0  !*sei_tmp.lpParameters  !appKnownSingular) {
my tests succeed, but there may be others, that I'm currently trying
to find.





Re: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 7]

2010-03-11 Thread Ilya Basin
Any news on this topic?





custom fake dll

2010-03-10 Thread Ilya Basin
Hi. Is it possible to make a custom dll that wraps some native linux
API? Will a newer version of Wine be able to load a fake dll built for
older release?

Is it necessary to create a new directory under dlls/ and update
configure scripts? Or I can use Wine's Makefile to build in a separate
directory, just like when you make custom kernel modules on linux?

Why every dll/exe that comes with wine is fake and real code is
located in the corresponding *.so file? Even those depending only on
other dlls, like regedit.exe or msvcrt.dll. Only to speed-up
wineprefix creation?






Re[2]: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 4]

2010-03-08 Thread Ilya Basin
 JL  Also, those TEST_LPFILE_PARSED_OK macros are ugly, and hard to fix if
 JL  one place has a certain behavior, while another has different
 JL  behavior.  Just use ok directly wherever you're using the macro.
 Not convinced. What you say is good for reading, but not editing.
 If someone wants to change behavior , the other person
 defined in a macro, but only in one place, he can jast as simple
 copy-paste the definition and edit it.
 In any case, it's a free country (c).

PV I must agree with Juan here.

PV Apart from that, the macro TEST_LPFILE_PARSED_ok_condition is strange in 
PV itself as it checks for 'expected' and this is something you always set 
PV yourself.

PV I agree with you that it's a free country and stuff like this will 
PV always be up for debate but in the end it's AJ that commits the patches 
PV and he has expressed several times not being to fond about too much macros.

If it's well known, you had to tell me about macros at the beginning.
Sent try 6.


-- 





Re[2]: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 6]

2010-03-08 Thread Ilya Basin
PV On 03/08/2010 05:42 PM, Juan Lang wrote:
 Hi Ilya,
 I like this one rather better, thanks.  Especially the use of broken()
 makes it clearer what's happening.

 I think you could tidy it up just a little more:

 +expected = 33; sprintf(fileA, testfile, tmpdir);
 +rc=shell_execute(NULL, fileA, NULL, NULL);
 +todo_wine {
 +ok(rc==expected || (rc32  expected32),
 +expected %s (%d), got %s (%d), lpFile: %s \n,
 +expected==33 ? success : failure, expected, rc  32 ? 
 success : failure, rc, fileA
 +);
 +}

 In this case, expected is 33, so the expected == 33 is unneeded.
 Just replace %s (%d) with success (32).  Same below with the
 remaining ok expressions:  make them match the actual value of
 expected, rather than any possible value.  Otherwise, looks good to
 me.

PV Yep, I like this one better as well. The only thing I see is that you 
PV have ==expected and rc32 (which is both true in the above case). Is 
PV that to cover for OS differences? If so, please add some comments.
No, that's because I use the same expression for both failure and
success.
Now Juan tells me to have unique format string for each case. Let's stop
here already! I'm sure all of us are unable to predict what exactly
the guy with the commit power won't like in my patch. Quit taking
precautions, please.

-- 





Re[2]: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 4]

2010-03-06 Thread Ilya Basin
Hello. I'll wait for your comments for some time before trying to send
try 5.

JL I think you're still confused by the prohibition against using
JL GetVersion.  Your changes follow the letter of that edict, but not the
JL spirit:
lol, it's almost the same thing US customs inspector told a person
I know, when she started to travel too often.

JL What you want to do instead is to call shell_execute in any case
JL (unless doing so would crash.)  You'll want to check rc on succeeding
JL versions of Windows/Wine with ok, and mark it as broken elsewhere.
JL E.g.,
JL   rc = shell_execute(NULL, fileA, NULL, NULL);
JL   ok((rc==expected || rc32  expected32) || broken(rc == whatever
JL busted versions of Windows return), expected ...);
Thanks, I'll try to follow your recommendation.
However, the drawback of using broken() is when running on wine, an
.exe compiled with visual studio won't show test failures.
Only make test in tests directory will notice these failures.

JL Also, those TEST_LPFILE_PARSED_OK macros are ugly, and hard to fix if
JL one place has a certain behavior, while another has different
JL behavior.  Just use ok directly wherever you're using the macro.
Not convinced. What you say is good for reading, but not editing.
If someone wants to change behavior , the other person
defined in a macro, but only in one place, he can jast as simple
copy-paste the definition and edit it.
In any case, it's a free country (c).From 55dfdc06394130ca5c6ddac8d217e231f7501e44 Mon Sep 17 00:00:00 2001
From: Ilya Basin basini...@gmail.com
Date: Thu, 4 Mar 2010 21:48:58 +0300
Subject: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile 
[try 5]
To: wine-patches wine-patc...@winehq.org
Reply-To: wine-devel wine-devel@winehq.org

This should expose this bug:
http://bugs.winehq.org/show_bug.cgi?id=19385 ( the 'wine start'
launcher does not open MS Office documents that have spaces in their
path ). Although the title is misleading, many other tickets are
marked as duplicates of it.
It's not about spaces. It's about sometimes unneeded parsing of
SHELLEXECUTEINFO.lpFile, trying to extract arguments from it.

try 5:
replaced every win_skip() with broken()
try 4:
added these comments
try 3:
fixed test failures on 95/NT
new job results https://winetestbot.geldorp.nl/JobDetails.pl?Key=868
try 2:
added 4 todo_wine's to mark bad wine behavior
added GetProcAddress(hkernel32, AttachConsole) to detect XP/2k3
removed special case when XP emulates 9x because can't do it without
using GetVersion().

---
 dlls/shell32/tests/shlexec.c |   83 ++
 1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 5d5db34..59ab61e 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -797,6 +797,10 @@ static const char* testfiles[]=
 %s\\test file.sde,
 %s\\test file.exe,
 %s\\test2.exe,
+%s\\simple.shlexec,
+%s\\drawback_file.noassoc,
+%s\\drawback_file.noassoc foo.shlexec,
+%s\\drawback_nonexist.noassoc foo.shlexec,
 NULL
 };
 
@@ -852,6 +856,84 @@ static filename_tests_t noquotes_tests[]=
 {NULL, NULL, 0}
 };
 
+static void test_lpFile_parsed(void)
+{
+/* basename tmpdir */
+const char* shorttmpdir;
+
+const char *testfile;
+char fileA[MAX_PATH];
+
+int rc;
+int expected;
+
+GetTempPathA(sizeof(fileA), fileA);
+shorttmpdir = tmpdir + strlen(fileA);
+
+/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is 
undefined */
+SetEnvironmentVariableA(TEMP, fileA);
+
+#define TEST_LPFILE_PARSED_ok_(cond) ok((cond), expected %s (%d), got %s 
(%d), lpFile: %s \n, \
+expected==33 ? success : failure, expected, rc  32 ? success : 
failure, rc, fileA)
+
+#define TEST_LPFILE_PARSED_ok_condition() (rc==expected || (rc32  
expected32))
+#define TEST_LPFILE_PARSED_ok() 
TEST_LPFILE_PARSED_ok_(TEST_LPFILE_PARSED_ok_condition())
+
+/* existing drawback_file.noassoc prevents finding 
drawback_file.noassoc foo.shlexec on wine */
+testfile = %s\\drawback_file.noassoc foo.shlexec;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_ok(); }
+
+/* if quoted, existing drawback_file.noassoc not prevents finding 
drawback_file.noassoc foo.shlexec on wine */
+testfile = \%s\\drawback_file.noassoc foo.shlexec\;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_ok_(TEST_LPFILE_PARSED_ok_condition() || broken(rc == 
2) /* Win95/NT4 */ );
+
+/* error should be 2, not 31 */
+testfile = \%s\\drawback_file.noassoc\ foo.shlexec;
+expected = 2; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_ok();
+
+/* command not works on wine (and real win9x

Re: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 3]

2010-03-04 Thread Ilya Basin
Hello. I can see you ran my tests on a test bot and they don't fail.
Thanks. Why don't you put the patch into git? I'm willing to fix the
code of the dll itself after the tests are there.





Re[2]: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 3]

2010-03-04 Thread Ilya Basin
PV On 03/04/2010 10:56 AM, Ilya Basin wrote:
 Hello. I can see you ran my tests on a test bot and they don't fail.
 Thanks. Why don't you put the patch into git? I'm willing to fix the
 code of the dll itself after the tests are there.


PV I was just acting as a manual patchwatcher here ;)

PV Alexandre is the only one committing to the Wine git repository.

PV When you send another try of your patches, please make sure you add some 
PV comments about what changed compared to the previous one. The reason I 
PV ran your tests was just because Try2 had some test failures on 95/NT and 
PV Try3 didn't mention this was fixed.


So, should I send try 4 with comments and link to the job?

-- 





Re: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 2]

2010-02-17 Thread Ilya Basin
Hi! Please comment on try 2 of the patch. Will you accept it?

IB Hi! This should expose this bug:
IB http://bugs.winehq.org/show_bug.cgi?id=19385 ( the 'wine start'
IB launcher does not open MS Office documents that have spaces in their
IB path ). Although the title is misleading, many other tickets are
IB marked as duplicates of it.
IB It's not about spaces. It's about sometimes unneeded parsing of
IB SHELLEXECUTEINFO.lpFile, trying to extract arguments from it. Why?
IB Or maybe some other part of wine relies on this behavior?

IB Succeeds on 98 se, 2k  xp.
IB 4 tests fail on wine
IB ---
IB  dlls/shell32/tests/shlexec.c |   87 
++
IB  1 files changed, 87 insertions(+), 0 deletions(-)

IB diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
IB index c673f0a..d575d22 100644
IB --- a/dlls/shell32/tests/shlexec.c
IB +++ b/dlls/shell32/tests/shlexec.c
IB @@ -797,6 +797,10 @@ static const char* testfiles[]=
IB  %s\\test file.sde,
IB  %s\\test file.exe,
IB  %s\\test2.exe,
IB +%s\\simple.shlexec,
IB +%s\\drawback_file.noassoc,
IB +%s\\drawback_file.noassoc foo.shlexec,
IB +%s\\drawback_nonexist.noassoc foo.shlexec,
IB  NULL
IB  };
IB  
IB @@ -852,6 +856,88 @@ static filename_tests_t noquotes_tests[]=
IB  {NULL, NULL, 0}
IB  };
IB  
IB +static void test_lpFile_parsed(void)
IB +{
IB +/* basename tmpdir */
IB +const char* shorttmpdir;
IB +
IB +const char *testfile;
IB +char fileA[MAX_PATH];
IB +
IB +int rc;
IB +int expected;
IB +
IB +HMODULE hkernel32 = GetModuleHandle(kernel32);
IB +BOOL isreallyXP2k3plus = NULL != GetProcAddress(hkernel32, 
AttachConsole);
IB +
IB +GetTempPathA(sizeof(fileA), fileA);
IB +shorttmpdir = tmpdir + strlen(fileA);
IB +
IB +/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP 
is undefined */
IB +SetEnvironmentVariableA(TEMP, fileA);
IB +
IB +#define TEST_LPFILE_PARSED_OK_() (rc==expected || rc32  expected32)
IB +#define TEST_LPFILE_PARSED_OK() ok(TEST_LPFILE_PARSED_OK_(), expected 
%s (%d), got %s (%d), lpFile: %s \n, expected==33 ? success : failure, 
expected, rc  32 ? success : failure, rc, fileA)
IB +
IB +/* existing drawback_file.noassoc prevents finding 
drawback_file.noassoc foo.shlexec on wine */
IB +testfile = %s\\drawback_file.noassoc foo.shlexec;
IB +expected = 33; sprintf(fileA, testfile, tmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +todo_wine { TEST_LPFILE_PARSED_OK(); }
IB +
IB +/* if quoted, existing drawback_file.noassoc not prevents finding 
drawback_file.noassoc foo.shlexec on wine */
IB +testfile = \%s\\drawback_file.noassoc foo.shlexec\;
IB +expected = 33; sprintf(fileA, testfile, tmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +TEST_LPFILE_PARSED_OK();
IB +
IB +/* error should be 2, not 31 */
IB +testfile = \%s\\drawback_file.noassoc\ foo.shlexec;
IB +expected = 2; sprintf(fileA, testfile, tmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +TEST_LPFILE_PARSED_OK();
IB +
IB +/* command not works on wine (and real win9x and w2k) */
IB +if (isreallyXP2k3plus) {
IB +testfile = \\%s\\simple.shlexec\\;
IB +expected = 33; sprintf(fileA, testfile, tmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +todo_wine { TEST_LPFILE_PARSED_OK(); }
IB +} else {
IB +win_skip(ShellExecute('\\command\\', ...) only works on 
XP/2k3 or newer\n);
IB +}
IB +
IB +/* nonexisting drawback_nonexist.noassoc not prevents finding 
drawback_nonexist.noassoc foo.shlexec on wine */
IB +testfile = %s\\drawback_nonexist.noassoc foo.shlexec;
IB +expected = 33; sprintf(fileA, testfile, tmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +TEST_LPFILE_PARSED_OK();
IB +
IB +/* is SEE_MASK_DOENVSUBST default flag? Should only be when XP 
emulates 9x (XP bug or real 95 or ME behavior ?) */
IB +testfile = %%TEMP%%\\%s\\simple.shlexec;
IB +expected = 2; sprintf(fileA, testfile, shorttmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +todo_wine { TEST_LPFILE_PARSED_OK(); }
IB +
IB +/* quoted */
IB +testfile = \%%TEMP%%\\%s\\simple.shlexec\;
IB +expected = 2; sprintf(fileA, testfile, shorttmpdir);
IB +rc=shell_execute(NULL, fileA, NULL, NULL);
IB +todo_wine { TEST_LPFILE_PARSED_OK(); }
IB +
IB +/* test SEE_MASK_DOENVSUBST works */
IB +testfile = %%TEMP%%\\%s\\simple.shlexec;
IB +expected = 33; sprintf(fileA, testfile, shorttmpdir);
IB +rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, 
fileA, NULL, NULL);
IB +TEST_LPFILE_PARSED_OK();
IB +
IB +/* quoted */
IB +testfile = \%%TEMP%%\\%s\\simple.shlexec\;
IB +expected = 33; sprintf(fileA, testfile, shorttmpdir);
IB +rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, 
fileA, NULL, NULL);
IB +

Re[2]: shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile [try 2]

2010-02-17 Thread Ilya Basin
PV On 02/17/2010 09:51 AM, Ilya Basin wrote:
 Hi! Please comment on try 2 of the patch. Will you accept it?
 IB  +/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if 
 TEMP is undefined */
 IB  +SetEnvironmentVariableA(TEMP, fileA);

PV I'm still not convinced you need this but I think that's minor.

PV I ran your tests on winetestbot and there are 2 failures for Win95 and NT4:

PV https://winetestbot.geldorp.nl/JobDetails.pl?Key=733

Added 2 win_skip's for these failures. Tested on NT4. Don't have 95
though.

---
 dlls/shell32/tests/shlexec.c |   98 ++
 1 files changed, 98 insertions(+), 0 deletions(-)
 mode change 100644 = 100755 dlls/shell32/tests/shlexec.c

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
old mode 100644
new mode 100755
index c673f0a..150856c
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -797,6 +797,10 @@ static const char* testfiles[]=
 %s\\test file.sde,
 %s\\test file.exe,
 %s\\test2.exe,
+%s\\simple.shlexec,
+%s\\drawback_file.noassoc,
+%s\\drawback_file.noassoc foo.shlexec,
+%s\\drawback_nonexist.noassoc foo.shlexec,
 NULL
 };
 
@@ -852,6 +856,99 @@ static filename_tests_t noquotes_tests[]=
 {NULL, NULL, 0}
 };
 
+static void test_lpFile_parsed(void)
+{
+/* basename tmpdir */
+const char* shorttmpdir;
+
+const char *testfile;
+char fileA[MAX_PATH];
+
+int rc;
+int expected;
+
+HMODULE hkernel32 = GetModuleHandle(kernel32);
+BOOL isreallyXP_2k3_plus = NULL != GetProcAddress(hkernel32, 
AttachConsole);
+BOOL isreally98_2k_plus = NULL != GetProcAddress(hkernel32, 
GetLongPathNameA);
+
+GetTempPathA(sizeof(fileA), fileA);
+shorttmpdir = tmpdir + strlen(fileA);
+
+/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is 
undefined */
+SetEnvironmentVariableA(TEMP, fileA);
+
+#define TEST_LPFILE_PARSED_OK_() (rc==expected || rc32  expected32)
+#define TEST_LPFILE_PARSED_OK() ok(TEST_LPFILE_PARSED_OK_(), expected %s 
(%d), got %s (%d), lpFile: %s \n, expected==33 ? success : failure, 
expected, rc  32 ? success : failure, rc, fileA)
+
+/* existing drawback_file.noassoc prevents finding 
drawback_file.noassoc foo.shlexec on wine */
+testfile = %s\\drawback_file.noassoc foo.shlexec;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK(); }
+
+/* quoted lpFile not works on real win95 and nt4 */
+if (isreally98_2k_plus) {
+/* if quoted, existing drawback_file.noassoc not prevents finding 
drawback_file.noassoc foo.shlexec on wine */
+testfile = \%s\\drawback_file.noassoc foo.shlexec\;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+} else {
+win_skip(ShellExecute('\command\', ...) only works on 98/2k or 
newer\n);
+}
+
+/* error should be 2, not 31 */
+testfile = \%s\\drawback_file.noassoc\ foo.shlexec;
+expected = 2; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+
+/* command not works on wine (and real win9x and w2k) */
+if (isreallyXP_2k3_plus) {
+testfile = \\%s\\simple.shlexec\\;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK(); }
+} else {
+win_skip(ShellExecute('\\command\\', ...) only works on XP/2k3 or 
newer\n);
+}
+
+/* nonexisting drawback_nonexist.noassoc not prevents finding 
drawback_nonexist.noassoc foo.shlexec on wine */
+testfile = %s\\drawback_nonexist.noassoc foo.shlexec;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+
+/* is SEE_MASK_DOENVSUBST default flag? Should only be when XP emulates 9x 
(XP bug or real 95 or ME behavior ?) */
+testfile = %%TEMP%%\\%s\\simple.shlexec;
+expected = 2; sprintf(fileA, testfile, shorttmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK(); }
+
+/* quoted */
+testfile = \%%TEMP%%\\%s\\simple.shlexec\;
+expected = 2; sprintf(fileA, testfile, shorttmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK(); }
+
+/* test SEE_MASK_DOENVSUBST works */
+testfile = %%TEMP%%\\%s\\simple.shlexec;
+expected = 33; sprintf(fileA, testfile, shorttmpdir);
+rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI, NULL, 
fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+
+/* quoted lpFile not works on real win95 and nt4 */
+if (isreally98_2k_plus) {
+/* quoted */
+testfile = \%%TEMP%%\\%s\\simple.shlexec\;
+expected = 33; sprintf(fileA

Re[2]: [PATCH] shell32/tests: add tests for the parser of SHELLEXECUTEINFO.lpFile (resend)

2010-02-12 Thread Ilya Basin
Thanks for review. Not sending to wine-patches this time. New patch is
in the bottom. What's better, to attach a generated patch or to use it
as a message body?

PV On 02/11/2010 03:37 PM, Ilya Basin wrote:
 Hi! This should expose this bug:
 http://bugs.winehq.org/show_bug.cgi?id=19385 ( the 'wine start'
 launcher does not open MS Office documents that have spaces in their
 path ). Although the title is misleading, many other tickets are
 marked as duplicates of it.
 It's not about spaces. It's about sometimes unneeded parsing of
 SHELLEXECUTEINFO.lpFile, trying to extract arguments from it. Why?
 Or maybe some other part of wine relies on this behavior?
 Tested on 98 se, 2k  xp.

PV Hi Ilya,

PV As Wine doesn't do the right thing (according to your tests), all 
PV failing Wine tests should be marked as such. We have a todo_wine 
PV construct for that.
added 4 todo_wine's

PV We generally do not want any real version checking in the tests. Tests
PV should decide based on behavior on what platform they are.
added GetProcAddress(hkernel32, AttachConsole) to detect XP/2k3
removed special case when XP emulates 9x because can't do it without
using GetVersion().

 +
 +GetTempPathA(sizeof(fileA), fileA);
 +shorttmpdir = tmpdir + strlen(fileA);
 +
 +/* ensure tmpdir is in %TEMP% */
 +SetEnvironmentVariableA(TEMP, fileA);

PV Why is this necessary?
/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is 
undefined */

 +/* is SEE_MASK_DOENVSUBST default flag? Should only be when XP emulates 
 9x */
 +{

PV Any particular reason for this indentation?
OK

---
 dlls/shell32/tests/shlexec.c |   87 ++
 1 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index c673f0a..d575d22 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -797,6 +797,10 @@ static const char* testfiles[]=
 %s\\test file.sde,
 %s\\test file.exe,
 %s\\test2.exe,
+%s\\simple.shlexec,
+%s\\drawback_file.noassoc,
+%s\\drawback_file.noassoc foo.shlexec,
+%s\\drawback_nonexist.noassoc foo.shlexec,
 NULL
 };
 
@@ -852,6 +856,88 @@ static filename_tests_t noquotes_tests[]=
 {NULL, NULL, 0}
 };
 
+static void test_lpFile_parsed(void)
+{
+/* basename tmpdir */
+const char* shorttmpdir;
+
+const char *testfile;
+char fileA[MAX_PATH];
+
+int rc;
+int expected;
+
+HMODULE hkernel32 = GetModuleHandle(kernel32);
+BOOL isreallyXP2k3plus = NULL != GetProcAddress(hkernel32, 
AttachConsole);
+
+GetTempPathA(sizeof(fileA), fileA);
+shorttmpdir = tmpdir + strlen(fileA);
+
+/* ensure tmpdir is in %TEMP%: GetTempPath() can succeed even if TEMP is 
undefined */
+SetEnvironmentVariableA(TEMP, fileA);
+
+#define TEST_LPFILE_PARSED_OK_() (rc==expected || rc32  expected32)
+#define TEST_LPFILE_PARSED_OK() ok(TEST_LPFILE_PARSED_OK_(), expected %s 
(%d), got %s (%d), lpFile: %s \n, expected==33 ? success : failure, 
expected, rc  32 ? success : failure, rc, fileA)
+
+/* existing drawback_file.noassoc prevents finding 
drawback_file.noassoc foo.shlexec on wine */
+testfile = %s\\drawback_file.noassoc foo.shlexec;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK(); }
+
+/* if quoted, existing drawback_file.noassoc not prevents finding 
drawback_file.noassoc foo.shlexec on wine */
+testfile = \%s\\drawback_file.noassoc foo.shlexec\;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+
+/* error should be 2, not 31 */
+testfile = \%s\\drawback_file.noassoc\ foo.shlexec;
+expected = 2; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+
+/* command not works on wine (and real win9x and w2k) */
+if (isreallyXP2k3plus) {
+testfile = \\%s\\simple.shlexec\\;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK(); }
+} else {
+win_skip(ShellExecute('\\command\\', ...) only works on XP/2k3 or 
newer\n);
+}
+
+/* nonexisting drawback_nonexist.noassoc not prevents finding 
drawback_nonexist.noassoc foo.shlexec on wine */
+testfile = %s\\drawback_nonexist.noassoc foo.shlexec;
+expected = 33; sprintf(fileA, testfile, tmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+TEST_LPFILE_PARSED_OK();
+
+/* is SEE_MASK_DOENVSUBST default flag? Should only be when XP emulates 9x 
(XP bug or real 95 or ME behavior ?) */
+testfile = %%TEMP%%\\%s\\simple.shlexec;
+expected = 2; sprintf(fileA, testfile, shorttmpdir);
+rc=shell_execute(NULL, fileA, NULL, NULL);
+todo_wine { TEST_LPFILE_PARSED_OK