Inter-process communication using Events c++ - multithreading

I need to work with file using CreateFile() and CreateEventEx() functions.
For example,i open two instance of my programm,in first i open or create a file,in second i give a command CloseHandle,which i created in first instance.Help,how to implement this.

Related

Flow generation option that will create separate flow files per sub-flow?

I use sub-flows extensively and would like to have an option to generate a separate ATE flow file per sub-flow (e.g. on V93K a separate .tf file). Is this possible? Perhaps something like this, wih the default being the current behavior:
import :my_subflow, generate_standalone: true
The reason this is valuable is that we use a test program assembler that can merge multiple flow files together given a sequence of flow files. This saves on test program load time for debug sessions.
thx
There is no switch like that currently, but note that you can generate sub-flows directly:
origen p program/_my_subflow.rb
The leading "_" in the name means that they will be not be generated as standalone flows if you point the program generator to the directory (origen p program/), but if you explicitly ask it to generate that file then it will.

How to run one feature file as initialization (i.e. before all other feature files) in cucumber-jvm?

I have a cucumber feature file 'A' that serves as setting up environment (data clean up and initialization). I want to have it executed before all other feature files can run.
It's it kind of like #before hook as in http://zsoltfabok.com/blog/2012/09/cucumber-jvm-hooks/. However, that does not work because my feature files 'A' contains hundreds of cucumber steps and it is not as simple as:
#Before
public void beforeScenario() {
tomcat.start();
tomcat.deploy("munger");
browser = new FirefoxDriver();
}
instead it's better to be able to run 'A' as a feature file as a whole.
I've searched around but did not find a answer. I am so surprised that no one has this type of requirement before.
The closest i found is 'background'. But that means i can have only one huge feature file with the content of 'A' as 'background' at the top, and rest of my test in the same file. I really do not want to do that.
Any suggestions?
By default, Cucumber features are run single thread in order by:
Alphabetically by feature file directory
Alphabetically by feature file name within directory
Scenario execution is then by order within the feature file.
So have your initialization feature in the first directory (alhpabetically) with a file name that sorts first (alphabetically) in that directory.
That being said it is generally a bad practice to require an execution order in your feature files. We run our feature files in parallel so order is meaningless. For Jenkins or TeamCity you could add a build step that executes the one feature file followed by a second build step that executes the rest of your feature files.
I have also a project, where we have a single feature file, that contains a very long scenario called Scenario: Test data with a lot of very long scenarios, like this:
Given the system knows about the following employees
|uuid|user-key|name|nickname|
|1|0101140000|Anna|annie|
... hundreds of lines like this follow ...
We see this long SystemKnows scenarios as quite valuable, so that our testers, Product Owner and developers have a baseline of what data are in the system. Our domain is quite complex, and we need this baseline of reference data for everyone to be able to understand the tests.
(These reference data become almost like well known personas, and are a shared team metaphore)
In the beginning, we were relying on the alphabetic naming convention, to have the AAA.feature to be run first.
Later, we discovered that this setup was brittle, and decided to use the following trick, inspired by the PageObject pattern:
Add a background with the single line Given(~'^I set test data for all feature files$')
In the step definition, have a factory to create the test data, and make sure inside the factore method, that it is only created once, like testFactory.createTestData()
In this way, you have both the convenience of expressing reference setup as a scenario, that enhances team communication, but you also have a stable test setup.
Hope this is helpful!
Agata

Is there a standard Linux library for "lock files"?

Suppose I have a folder and I want only one instance of my application working on it at a time. I can only synchronize via the filesystem itself. Often times this is a accomplished with something like a .lock_file where if that's present I know another instance is currently using it. Are there any standard libraries that handle this sort of thing?
If you are using C/C++, see fclnt or flock :
Locking files in linux with c/c++
If you are using java, see FileChannel lock method
and
How can I lock a file using java (if possible)
You also can check for the existence of the .lock_file opening it with
open(pathname, O_CREAT | O_EXCL, 0644),
see open man page, it creates and opens the file and returns EEXIST if pathname exists.
In java, calling to File method createNewFile() can be use to create atomically the .lock_file

Using VBA to control another program entirely

I'm currently working on simplifying a process at work. It involves a Chatillon DFIS Force Meter which uses a serial connection to transmit data. The data gets sent to the Chattillon program as text and can only be saved as a .dat file. I'm trying to set up an Excel workbook that can just automatically open the program and have different commands to put the information straight into Excel. The Commands would involve changing the units, zeroing the sensor, and transmitting.
I've done some looking around and found that the Shell feature gives you access to opening the file and should help allow you to control it but I haven't found a way to call and manipulate the program through Excel.
Chatillon Program, basically buttons to click with a mouse
Excel and VBA can control external applications if they have a COM interface - that is to say, if you can declare the application as an object, create an instance of the object, and see its methods and attributes.
If you can possibly get hold of a COM wrapper for your program, do it that way.
If you can't... You won't enjoy doing it using I/O streams and a Windows Shell object, because command-line DOS interfaces aren't particularly friendly as a User Interface, and they are flakier than breakdancing in a pastry factory when you try to use them as an API in VBA.
Firstly, you need the 'WshShell' object exposed by the Windows Script Host Object Model. You can declare and instantiate it by late binding as shown:
Dim objWshell As Object
Set objWshell = CreateObject("WScript.Shell")
But the correct method (which will give you Intellisense drop-downs of the properties and methods) is to use the 'Tools:References...' dialog to create a reference to the parent library, which is usually found at C:\Windows\System32\wshom.ocx
You can then declare the Shell object as:
Dim objWshell As IWshRuntimeLibrary.WshShell
Set objWshell = New IWshRuntimeLibrary.WshShell
Running a command-line executable and reading the I/O streams in VBA:
This is an example that opens a command window and runs a command-line executable, feeding it a command-line switch '-s' and a parameter encapsulated in double quotes.
Note that the executable I'm running is NOT 'regsvr32.exe' - my shell object is executing cmd.exe, and that is the source and sink of the I/O streams.
You can, of course, run your application directly. It might work. But it is very common for the output stream to lock or 'hang' your calling function and its VBA thread when you call .StdOut.ReadLine or .StdOut.ReadAll - you have been warned.
With objWshell.Exec("CMD /K")
.StdIn.WriteBlankLines 3
.StdIn.WriteLine "C:"
.StdIn.WriteLine "CD C:\"
.StdIn.WriteLine "regsvr32.exe -s " & Chr(34) & "%LIBDIR%\FXPricer.dll" & Chr(34)
.StdIn.WriteBlankLines 1
Do Until .StdOut.AtEndOfStream
Debug.Print .StdOut.ReadLine
Loop
Do Until .StdErr.AtEndOfStream
Debug.Print .StdOut.ReadLine
Loop
.Terminate
End With
Share and Enjoy. And, as always, watch out for line breaks inserted by your browser (or by StackOverflow's textbox interface) in the source code samples.

Application to accept arguments while running

I am using visual studio 2008 and MFC. I accept arguments using a subclass of CCommandLineInfo and overriding ParseParam().
Now I want to pass these arguments to the application while running. For example "test.exe /start" and then to type in the console "test.exe /initialize" to be initialized again.
is there any way to do that?
Edit 1: Some clarifications. My program starts with "test.exe /start". I want to type "test.exe /initialize" and initialize the one and only running process (without closing/opening). And by initialize I mean to read a different XML file, to change some values of the interface and other things.
I cannot think of an easy way to accomplish what you're asking about.
However, you could develop your application to specifically receive commands, and given those commands take any actions you wanted based upon receiving them. Since you're already using MFC, you can do this rather easily. Create a Window (HWND) for your application and register it. It doesn't have to be visible (this won't necessarily make you application a GUI application). Implement a WndProc, and define specific messages that you will receive based on WM_USER + <xxx>.
First and obvious question is why you want to have threads, instead of processes.
You may use GetCommandLine and CommandLineToArgvW to get the fully formatted command line. Detect the arguments, and the call CreateProcess or ShellExecute passing /watever to spawn the process. You may also want to use GetModuleBaseName to get the name of your own EXE.

Resources