Xvfb - start or attach a window manager to xvfb - xvfb

For testing purpose, I used Xvfb.
Today, I want to do some test with wmctrl commmand. I do some test in python like this :
display = ":99"
pXvfb = subprocess.Popen(["Xvfb", display, "-screen", "0", "1024x768x24"])
# wait that xvfb is up
time.sleep(1)
os.environ["DISPLAY"] = display
p = subprocess.Popen( ["wmctrl", "-l" ] )
p.wait()
pXvfb.terminate()
In this test, wmctrl says :
Cannot get client list properties.
(_NET_CLIENT_LIST or _WIN_CLIENT_LIST)
I think, it's normal because I haven't any window manager attach to my Xvfb.
How to start a windows manager (Enlighenment should be good for my case) to manage only Xvfb ?

After some days of works, I can answer myself. Solution is easy as possible : just start windows manager with variable DISPLAY set. So in my python script, I just do :
display = ":99"
pXvfb = subprocess.Popen(["Xvfb", display, "-screen", "0", "1024x768x24"])
# wait that xvfb is up
time.sleep(1)
os.environ["DISPLAY"] = display
# start windows manager
pWM = subprocess.Popen( ["/usr/bin/enlightenment_start", ] )
p = subprocess.Popen( ["wmctrl", "-l" ] )
p.wait()
pXvfb.terminate()

Related

How to retrive information of desktop number for each monitor under linux (by vala language)

I'm working on a plank plugin recently, I want this plugin to display current desktop number and total number of desktops under current monitor.
I'm trying to get above numbers by examing root window's properties such as _NET_CURRENT_DESKTOP, _NET_NUMBER_OF_DESKTOPS, _NET_DESKTOP_NAMES, below is an example output of xprop command under linux:
>> xprop -frame
_NET_WM_ICON_NAME(UTF8_STRING) =
_NET_ACTIVE_WINDOW(WINDOW): window id # 0x3c005d0
_NET_CLIENT_LIST(WINDOW): window id # 0x3c005d0, 0x4200003, 0x3200002, 0x3c00007, 0x2a00003, 0x1c00003, 0x2800003
_NET_CLIENT_LIST_STACKING(WINDOW): window id # 0x1c00003, 0x3200002, 0x2800003, 0x2a00003, 0x3c00007, 0x4200003, 0x3c005d0
XIM_SERVERS(ATOM) = #server=fcitx5
XFree86_DDC_EDID1_RAWDATA(INTEGER) = ......
AT_SPI_BUS(STRING) = "unix:path=/run/user/974/at-spi/bus_0,guid=d2b64617d145d6b9bd20e88d6332dce1"
_NET_CURRENT_DESKTOP(CARDINAL) = 2
_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 6
_NET_DESKTOP_NAMES(UTF8_STRING) = "Work", "Work", "Work", "2", "2", "3"
_NET_SUPPORTING_WM_CHECK(WINDOW): window id # 0x400005
And I've finished a demo like this, W is first desktop name's first letter, 2 is second desktop's name:
But there is still some problems:
PROBLEM 1 I'm using vala to subscribe signal of workspace change, but I can not get callback while the newly create Desktop is empty, in other ways, I can only get callback when there is at least one window in newly created desktop.
Wnck.Screen screen = Wnck.Screen.get_default ();
// will not be invoked in handle_workspace_changed
// if the newly created desktop is empty
screen.active_workspace_changed.connect_after (handle_workspace_changed);
PROBLEM 2 I want get current desktop and total desktop numbers for each monitor, but the windows properties above is the total number of all my 3 monitors. Such as I have these desktops of each monitor:
Monitor 1: Work
Monitor 2: Work、2、3
Monitor 3: Work、2
Assume I'm currently on Monitor 3 desktop 2(empty desktop).
The root window actual properties will be :
_NET_CURRENT_DESKTOP(CARDINAL) = 2
_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 6
_NET_DESKTOP_NAMES(UTF8_STRING) = "Work", "Work", "Work", "2", "2", "3"
These is not the correct behavior I want, what expect is:
_NET_CURRENT_DESKTOP(CARDINAL) = 1 // because I'm currently on desktop 2, but this value will not change until I put some window in desktop 2 (problem 1)
_NET_NUMBER_OF_DESKTOPS(CARDINAL) = 2 // Monitor 3 has 2 desktops which are: Work、2
_NET_DESKTOP_NAMES(UTF8_STRING) = "Work", "2" // Monitor 3 has 2 desktops which are: Work、2
So I'm current on _NET_CURRENT_DESKTOP(CARDINAL) = 1 desktop with name _NET_DESKTOP_NAMES(UTF8_STRING)[1] = "2", and there are _NET_NUMBER_OF_DESKTOPS(CARDINAL) = 2 desktops on this monitor.
So any suggestions to solve problem 1&2 ?

Information passing between extra_actions

I have an action_listener:
action_listener(
name = "foo_listen",
mnemonics = [
"Foo", # Foo might usually take several minutes
],
extra_actions = [
"foo_action_pre", # Start some processing
"foo_action_post", # Finish parts of processing that needs action output
],
)
In foo_action_pre, I set
out_templates=[
"foo_action_pre_data",
],
in order to pass information to foo_action_post.
Now when I add $(location foo_action_pre_data) to the cmd of foo_action_post Bazel complains, that it is not a prereq.
No matter whether I add that to tools or data though, it never is detected as a prereq. How can I declare the correct dependency?
You have to use $(output foo_action_pre_data) instead of $(location foo_action_pre_data).
See extra_action.cmd.

Jenkins and QTP 10.0 integration

I have integrated Jenkins and QTP 10.0. I am able to run my test scripts from Jenkins. Only issue I am facing is that QTP output result is not displaying on Jenkins console. Below is the VB script I wrote :
Dim App,strDrive, strfoldername,objFSO, objFolder, strPath, TestScriptpath1, oFSO
' Launch QuickTest Professional and make it visible.
Set App = CreateObject("QuickTest.Application")
Set qtResultsObj = CreateObject("QuickTest.RunResultsOptions")
Set fsobj=CreateObject("Scripting.FileSystemObject")
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("C:\Batch File\QTP_Scripts.xls")
Set xlSheet = xlBook.WorkSheets("Sheet1")
'Set stdout = fsobj.GetStandardStream (1)
'stdout.WriteLine "This will go to standard output."
Set WshShell = CreateObject("WScript.Shell")
App.Launch
App.Visible = True
strfoldername="_Result"
'Read all the Test path from the Excel and Loop through all the tests.
For ix = 2 To xlSheet.UsedRange.Rows.Count
TestScriptpath = xlSheet.Cells(ix, 1).value
TestScriptpath1=Split(TestScriptpath, "\")
'Open the test in QuickTest Professional.
App.Open TestScriptpath,True,False
'Create Environment Variables to pass the results from QTP to runner.vbs
APP.Test.Environment.Value("JenkinsFlag") = "Y"
APP.Test.Environment.Value("JenkinsTestCaseDescription") = TestScriptpath1(2)
sResultFolderPath="C:\BUILD_TAG\"
'' Get the test object.
Set qtTest = App.Test
ResultFolderPath1=sResultFolderPath&TestScriptpath1(2)&strfoldername
Set objFolder = fsobj.CreateFolder(sResultFolderPath1)
'Execute the test. Instruct QuickTest Professional to wait for the test to finish executing.
'This statement specifies a test results location.
qtResultsObj.ResultsLocation=sResultFolderPath1
qtTest.Run qtResultsObj, True
StrResult=qtTest.LastRunResults.Status
xlSheet.Cells(ix, 2).value=StrResult
'Write the result in the console
While APP.Test.isRunning
If APP.Test.Environment.Value("JenkinsFlag") = "Y" Then
'APP.Test.Environment.Value("JenkinsFlag") = "N"
' Show TC ID and Description
WshShell.StdOut.WriteLine APP.Test.Environment.Value("JenkinsTestCaseDescription")&TestScriptpath1(2)
'stdout.WriteLine APP.Test.Environment.Value("JenkinsTestCaseDescription") &TestScriptpath1(2)
'Wait till the test is executed & result is updated
While (APP.Test.Environment.Value("JenkinsTestCaseResult") = Reporter.runstatus AND APP.Test.isRunning)
WshShell.Sleep 1000
'stdout.Sleep 1000
Wend
'Show the Result
WshShell.StdOut.Write APP.Test.Environment.Value("JenkinsTestCaseResult")
'stdout.Write APP.Test.Environment.Value("Jenkins TestCaseResult")
End If
WshShell.Sleep 1000
'stdout.Sleep 1000
Wend
' Close the test.
qtTest.Close
Next
xlApp.ActiveWorkbook.Save
xlApp.ActiveWorkbook.Close
App.Quit
xlApp.Quit
If Not xlApp Is Nothing Then
xlApp.Quit
Set xlApp = Nothing
End If
'Release the created objects.
set qtResultsObj = nothing
set fsobj= nothing
set qtTest = nothing
set App = nothing
set xlApp = nothing
set xlBook = nothing
set xlSheet= nothing
I had created a sample runner file which will execute the test, show the results in the console & create a simple HTML file.
Check this for more info:
http://www.testautomationguru.com/qtpuft-jenkins-github-svn-integration/
Source code:
https://github.com/vinsguru/tag-qtp-jenkins-demo

Crash on BizHawk using a short LUA script

when using this very short script on the lua console on BizHawk (it's an emulator), Both the LUA console and BizHawk crashes at the same time.
I'd like to know if the error comes from my script or from BizHawk, her's the script: (What it is supposed to do is check if the player is not moving for a certain time period [TimeoutConstant] and if he is [cause he's dead, stuck or afk] the script loads a saved state called Filename and it starts again. Here's the script:
Filename = "yolo.state"
TimeoutConstant = 80
rightmost = 0
timeout = TimeoutConstant
function initializeRun()
savestate.load(Filename)
rightmost = 0
timeout = TimeoutConstant
end
function getPositions()
marioX = memory.read_s16_le(0x94)
marioY = memory.read_s16_le(0x96)
local layer1x = memory.read_s16_le(0x1A);
local layer1y = memory.read_s16_le(0x1C);
screenX = marioX-layer1x
screenY = marioY-layer1y
end
initializeRun()
while true do
getPositions()
if marioX > rightmost then
rightmost = marioX
timeout = TimeoutConstant
end
if timeout <= 0 then
initializeRun()
end
timeout = timeout - 1
end
I assume by "crash" you mean "freeze" which is not at all the same thing. It's freezing because your script is putting the emulator into a busy loop. You didn't do anything to advance time in the emulator. The final two lines of your script need to be:
emu.frameadvance();
end
BTW, with emulator lua scripts, the name of the game being scripted is essential information.

Adding a mapped drive with WNetAddConnection2 is not accessible

I'm trying to map a drive using WNetAddCOnnection2 but there's something not quite right. The code that I am using from pinvoke.net and seems to work at first. If I am stepping through the code I get a 0 for a response and I am able to use System.IO.Directory.GetFiles() to inspect the new mapped drive which leads me to believe that credentials are fine.
The problem is that the drive is not available outside of the application. When I type net use from a command prompt I see the drive listed like this:
Unavailable L: \\<server>\<share> Microsoft Windows Network
When I try to access the drive I get either:
The system cannot find the drive specified.
or
The system cannot find the path specified.
Any help would be greatly appreciated.
Here's the nutshell of the code in question:
NETRESOURCE res = new NETRESOURCE();
res.iScope = RESOURCE_GLOBALNET;
res.iType = RESOURCETYPE_DISK;
res.iDisplayType = RESOURCEDISPLAYTYPE_SHARE;
res.iUsage = RESOURCEUSAGE_CONNECTABLE;
res.sRemoteName = share;
res.sLocalName = drive;
res.sProvider = null;
int iFlags = 0;
iFlags = CONNECT_UPDATE_PROFILE;
int iResult = WNetAddConnection2( ref res, psPassword, psUsername, iFlags );
The iResult always ends up equaling 0.
MSDN articles that may assist:
* WNetAddConnection2 - [http://msdn.microsoft.com/en-us/library/aa385413%28VS.85%29.aspx][1]
* NETRESOURCE - [http://msdn.microsoft.com/en-us/library/aa385353%28VS.85%29.aspx][2]
I reckon your problem is the display type where "res.iDisplayType = RESOURCEDISPLAYTYPE_SHARE". Perhaps try changing to a value of "0" (RESOURCEDISPLAYTYPE_GENERIC). So for example, what I generally use to map drives appears:
With Res
.dwScope = RES_SCOPE_GLOBALNET 'value 2
.dwType = RES_TYPE_DISK 'value of 1
.dwUsage = RES_USE_CONNECT 'value of 1
.localName = "x:" 'leave blank for no drive
.RemoteName = "\\\"
End With
lRes = WNetAddConnection2(Res, sPassword, sDomain & "\" & sPassword, RES_CNN_UPDATE_PROFILE)
If lRes = 0 Then
'Success
Else
'Error
End If
Always check your connections before & after calls from command prompt:
1a) From system making connection, list current connections:
net use
1b) From system connected too, list current sessions:
net session
To disconnect session, use API 'WNetCancelConnection2', my code following from above:
sServer = "\\\"
lRes = WNetCancelConnection2(sServer, RES_CNN_UPDATE_PROFILE, True)
If lRes `> 0 Then
'Success
Else
'Error
End If
Alternatively, simply making connections using 'net' command:
1) To map a drive letter:
net use `: \\`\` /user:`\` `
2) To map an IPC connection:
net use \\`\` /user:`\` `
Disconnecting using 'net' command:
1) Disconnecting mapped drive:
net use `: /delete
2) Disconnecting server share:
net use \\`\` /delete

Resources